-
Notifications
You must be signed in to change notification settings - Fork 116
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
utcToZonedTime() incorrect while toDate() correct around daylight saving time #31
Comments
It looks like the bug in utcToZonedTime goes with the system timezone. It works correctly on the GMT timezone system.
|
That's good to know! I'm on GMT so would probably not have managed to reproduce this. |
This is a real problem. let timeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone
let date = new Date() // choose the date +1h right after switching to Standart Time from Summer Time
let zonedDate = utcToZonedTime(value, timeZone);
let time = format(zonedDate, 'p', { timeZone })
console.log(time) // As the time zone is system, the time should match to `date` time, but it is not. Actually this formatting produces the same hour 3 times during moving from Summer Time to Standart Time |
Seems like the similar issue here: utcToZonedTime() adds an extra day to the returned date when converting date with time in range 23:00 - 23:59
|
Does not seem to be working at the moment in some edge cases of daylight saving time. See the issues of date-fns-tz, for instance: - marnusw/date-fns-tz#31 - marnusw/date-fns-tz#44 - marnusw/date-fns-tz#70
This might be fixed in version |
This year for "America/New_York" the daylight saving ended on Nov 3, 02:00 where it turned back 01:00. My browser is on a local "America/New_York" system.
toDate() gets this correctly but not utcToZonedTime(). utcToZonedTime() adds an hour even before 02:00.
The text was updated successfully, but these errors were encountered: