vvo / tzdb

🕰 Simplified, grouped and always up to date list of time zones, with major cities
MIT License
772 stars 53 forks source link

Wrong currentTimeOffsetInMinutes & currentTimeFormat #251

Open parekh-raj opened 2 years ago

parekh-raj commented 2 years ago

Please correct me if I'm wrong. 😇

I took an example of timezone America/Matamoros.

Context I used getTimeZones() function. For the above timezone(America/Matamoros), currentTimeOffsetInMinutes returns -360. As you could see here that we had a DST on Sunday, March 13, 2022. So now it's UTC-5.

Question Shouldn't it return -300 for currentTimeOffsetInMinutes?

Also the respective currentTimeFormat string is wrong. It's showing -06:00 ... instead of -05:00 ...

vvo commented 2 years ago

Hey there @parekh-raj, this is unfortunate. I've dug into this issue many times and here's how it works:

tzdb (this package) does an Intl.DateTimeFormat call to get the current time zone information for a zone. This call itself then use any version of the timezone database available inside Node.js.

So it really depends how up-to-date your Node.js version is. And even that, the latest Node.js version (17.7.2) is not completely up to date with the latest tzdata version (lagging two versions behind).

I am not sure there's a way to solve this easily. Maybe @eblokhin since you touched a bit on this subject you have some thoughts?

Thanks!