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:

1\. `echo getTime()`, when compiled to C, returns the proper timestamp with the 
proper timezone. The same thing compiled to JS returns timestamp with timezone 
UTC+0, which is incorrect. I filed an 
[issue](https://github.com/nim-lang/Nim/issues/5582) and proposed a 
[PR](https://github.com/nim-lang/Nim/pull/5581) to fix this behaviour, so what 
I need is someone with an expertise to tell me if I did a right thing.

2\. `parse` messes up hours when used with JS. `echo 
parse("2017-03-21T23:23:00+04:00", "yyyy-MM-dd'T'HH:mm:sszzz")` returns the 
correct `2017-03-21T23:23:00+04:00` when compiled to C and the completely wrong 
`2017-03-21T19:23:00+04:00` when compiled to JS. I found that this small change 
in 
[times.nim](https://github.com/nim-lang/Nim/blob/devel/lib/pure/times.nim#L621) 
fixes the issue:
    
    
    -     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.

Reply via email to