I'm currently trying to utilize Nim's JS backend for a real-life project. I find the experience quote pleasant, especially when dealing with times and dates. Procs provided by Nim's times module is much more superior to JS's built-in Date object methods.
However, there's a couple quirks due to differences in implementation that bug me:
- result.setSeconds(timeInfo.second + timeInfo.timezone)
+ result.setSeconds(timeInfo.second)
I'd be happy to send a PR but I wonder why timeInfo.timezone was there in the first place. Implicitly normalizing timestamps to UTC+0 is weird, let alone doing so without setting the timezone to 0, which returns an incorrect result. There must be something I'm missing.
I think your PR is fine. But it needs to be tested, the best way to create a reliable times module is to create lots of tests for it.
For #2, and other questions around why things are the way they are in the code, git blame is your friend. It's very likely that it was added through some other PR that fixed some other issue, if not then you can likely just fix it. Just make sure that you add tests for it :)