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

Clone creates unequal object when DST starts on midnight #826

Open
yefrem opened this issue Mar 23, 2020 · 0 comments
Open

Clone creates unequal object when DST starts on midnight #826

yefrem opened this issue Mar 23, 2020 · 0 comments
Labels

Comments

@yefrem
Copy link

yefrem commented Mar 23, 2020

TL;DR clone works incorrectly for an object pointing at the midnight DST start

There are several timezones that have DST start/end on midnight, e.g. Havana turns the clock 1 hour forward on Mar 8 00:00, which makes this time technically non-existent. When moving to this date with add(), moment is smart enough to understand it should be Mar 8 start. But if you clone the object, this info is lost and resulting object is not equal to it's source.

m = moment.tz('2020-03-01', 'America/Havana')
m.add(1, 'week')
console.log(m.format('YYYY-MM-DD')) // 2020-03-08
console.log(m.clone().format('YYYY-MM-DD')) // 2020-03-07
@ichernev ichernev added the bug label Aug 26, 2022
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

2 participants