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

[timezone] wrong toISOString() value with zone conversion and DST #1657

Open
dzonatan opened this issue Oct 5, 2021 · 1 comment
Open

[timezone] wrong toISOString() value with zone conversion and DST #1657

dzonatan opened this issue Oct 5, 2021 · 1 comment

Comments

@dzonatan
Copy link

dzonatan commented Oct 5, 2021

Describe the bug

// 'Europe/Vilnius' timezone => GMT+2, DST+1

// zone initialization - ok
dayjs.tz('2022-01-01T00:00:00.000Z', 'Europe/Vilnius').format()
// OUTPUT: '2022-01-01T00:00:00+02:00' ✅
dayjs.tz('2022-01-01T00:00:00.000Z', 'Europe/Vilnius').toISOString()
// OUTPUT: '2021-12-31T22:00:00.000Z' ✅

// zone conversion - fails
dayjs.utc('2021-12-31T22:00:00.000Z').tz('Europe/Vilnius').format()
// OUTPUT: '2022-01-01T00:00:00+02:00' ✅
dayjs.utc('2021-12-31T22:00:00.000Z').tz('Europe/Vilnius').toISOString()
// OUTPUT: '2021-12-31T23:00:00.000Z' ❌
// EXPECTED: '2021-12-31T22:00:00.000Z'

FIY: moment.js handles this properly.

Information

  • Day.js v1.10.7
  • OS: macOS Big Sur
@mr-short
Copy link

mr-short commented Oct 12, 2021

I am seeing similar 1 hour off issues with timezones (compared to momentjs). Central time is -5/-6 but dayjs is giving 7 hour offset?

dayjs('2021-01-01').tz('America/Chicago').toISOString()
'2021-01-01T07:00:00.000Z'

moment('2021-01-01').tz('America/Chicago').toISOString()
'2021-01-01T06:00:00.000Z'

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

No branches or pull requests

2 participants