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

Daylight Saving Time(DST) problem #3843

Closed
ynoval opened this issue Mar 17, 2017 · 1 comment
Closed

Daylight Saving Time(DST) problem #3843

ynoval opened this issue Mar 17, 2017 · 1 comment
Labels

Comments

@ynoval
Copy link

ynoval commented Mar 17, 2017

Due to DST the hour change in my country (Cuba) from GMT -5 to GMT -4 last saturday (March 11) - sunday(March 12)
https://www.timeanddate.com/time/dst/2017.html

But if I execute in Chrome Console the following commads the current week is not end at saturday as I expect it

Previous week is OK

moment().add(-1, 'week').startOf('week')
Moment {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: Locale, _d: Sun Mar 05 2017 00:00:00 GMT-0500 (CST)…}
moment().add(-1, 'week').endOf('week')
Moment {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: Locale, _d: Sat Mar 11 2017 23:59:59 GMT-0500 (CST)…}

Current Week # (Problem!!)

moment().startOf('week')
Moment {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: Locale, _d: Sun Mar 12 2017 01:00:00 GMT-0400 (CDT)…}
moment().endOf('week')
Moment {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: Locale, _d: Sun Mar 19 2017 00:59:59 GMT-0400 (CDT)…}

Next Week (OK)

moment().add(1, 'week').startOf('week')
Moment {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: Locale, _d: Sun Mar 19 2017 00:00:00 GMT-0400 (CDT)…}
moment().add(1, 'week').endOf('week')
Moment {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: Locale, _d: Sat Mar 25 2017 23:59:59 GMT-0400 (CDT)…}

the problem is just on this week the DST apply

Other information

console.log( (new Date()).toString())
Fri Mar 17 2017 19:35:32 GMT-0400 (CDT)

console.log((new Date()).toLocaleString())
3/17/2017, 7:36:00 PM

console.log( (new Date()).getTimezoneOffset())
240

console.log( navigator.userAgent)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

console.log(moment.version)
"2.17.1"

Regards
Yo.

@marwahaha marwahaha added the DST label Mar 21, 2017
@icambron
Copy link
Member

Yeah, startOf and endOf are buggy with DSTs. Going to close this as a duplicate of #2749 because I suspect it's the same issue.

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

No branches or pull requests

3 participants