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

src: workaround moment issue with DST transitions #73

Merged
merged 1 commit into from Oct 16, 2016

Conversation

santigimeno
Copy link
Contributor

@santigimeno santigimeno commented Oct 8, 2016

On DST end transition, setting the date to the startOf hour,
minute or second after having added 1 hour, minute or second
to the date, would result in the date set to the initial value causing
an infinite loop.

Example:

'use strict';

const moment = require('moment-timezone');

var m = moment(new Date('Sun Oct 30 2016 02:00:00 GMT+0200'));
console.log(m.toString(),
            '<-- Just 1 hour before the DST end @ Europe/Madrid');
m.add(1, 'hours');
console.log(m.toString(),
            '<-- DST end transition @ Europe/Madrid works correctly');
m.startOf('hour');
console.log(m.toString(),
            '<-- Smthing wrong?? It goes back to the previous hour');

Fixes: #72
Ref: moment/moment#2749

@santigimeno
Copy link
Contributor Author

Don't merge this yet. I think there can be an issue

@santigimeno
Copy link
Contributor Author

@harrisiirak it's ready now. PTAL

On DST end transition, setting the date to the `startOf` `hour`,
`minute` or `second` after having added 1 `hour`, `minute` or `second`
to the date, would result in the date set to the initial value causing
an infinite loop.

Example:

```js
'use strict';

const moment = require('moment-timezone');

var m = moment(new Date('Sun Oct 30 2016 02:00:00 GMT+0200'));
console.log(m.toString(),
            '<-- Just 1 hour before the DST end @ Europe/Madrid');
m.add(1, 'hours');
console.log(m.toString(),
            '<-- DST end transition @ Europe/Madrid works correctly');
m.startOf('hour');
console.log(m.toString(),
            '<-- Smthing wrong?? It goes back to the previous hour');
```

Fixes: harrisiirak#72
Ref: moment/moment#2749
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

Successfully merging this pull request may close these issues.

None yet

2 participants