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

formatInTimeZone(d, tz) shows the wrong time for one hour if the system zone has DST, even though tz doesn’t #258

Open
andersk opened this issue Nov 18, 2023 · 0 comments · May be fixed by #285

Comments

@andersk
Copy link

andersk commented Nov 18, 2023

My system time zone is America/Los_Angeles, where the start of daylight saving time on 2023-03-12 jumped the local time directly from 01:59 (-08:00) to 03:00 (-07:00). The UTC time zone had no such jump, of course, so one wouldn’t expect any issues formatting a UTC date between 01:59 (Z) and 03:00 (Z) for display in UTC.

However, because formatInTimeZone works internally by converting the time in the given zone to a “corresponding” local time in the system zone, this doesn’t work.

> formatInTimeZone(new Date('2023-03-12T01:05Z'), 'UTC', 'Pp z')
'03/12/2023, 1:05 AM UTC'
> formatInTimeZone(new Date('2023-03-12T02:05Z'), 'UTC', 'Pp z')  // expected 2:05 AM UTC
'03/12/2023, 3:05 AM UTC'
> formatInTimeZone(new Date('2023-03-12T03:05Z'), 'UTC', 'Pp z')
'03/12/2023, 3:05 AM UTC'
> formatInTimeZone(new Date('2023-03-12T04:05Z'), 'UTC', 'Pp z')
'03/12/2023, 4:05 AM UTC'

(Using [email protected] on Node.js 20.9.0 with America/Los_Angeles as the system time zone.)

@yangchristina yangchristina linked a pull request May 12, 2024 that will close this issue
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 a pull request may close this issue.

1 participant