Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong timezone for "Europe/Helsinki" #486

Closed
reinisp opened this issue Apr 19, 2017 · 1 comment
Closed

Wrong timezone for "Europe/Helsinki" #486

reinisp opened this issue Apr 19, 2017 · 1 comment

Comments

@reinisp
Copy link

reinisp commented Apr 19, 2017

When PC time is set to "(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius", new Date(4331480400000) and moment(4331480400000).tz('Europe/Helsinki') returns different results.

MomentJs returns 120 offset, but it should be 180.

Issue starts to appear starting from 2038 year.

Expected result moment(4331480400000).tz('Europe/Helsinki').date() returns the same result as new Date(4331480400000) .getDate() .

@mattjohnsonpint
Copy link
Contributor

mattjohnsonpint commented Apr 22, 2017

Sure.

moment(4331480400000).tz('Europe/Helsinki').format() // "2107-04-05T23:00:00+02:00"
moment(4331480400000).format()                       // "2107-04-06T00:00:00+03:00"

This is just too far out into the future.

Windows is assuming today's time zone rule will repeat year over year indefinitely.

Moment-timezone has to project transitions at specific times, for each and every year. We can't go on forever, or our data size would be prohibitively large. We currently stop just before year 2038. Past that, we have no transition data.

var untils = moment.tz.zone('Europe/Helsinki').untils;
untils[untils.length-1]  // Infinity
untils[untils.length-2]  // 2140045200000
moment.tz(2140045200000, 'Europe/Helsinki').format() // "2037-10-25T03:00:00+02:00"

Note that projecting transitions for any date in the future is making the assumption that nothing will change between now and then. The further out you go, the less likely this assumption is to be accurate. Even 2038 is a stretch, but we have to pick something.

Some time zones change with very little notice, so if you are working with future dates, you should be careful to reassess things often. See also: http://codeofmatt.com/2016/04/23/on-the-timing-of-time-zone-changes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants