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

Setting Timezone adds an extra hour #1664

Open
mr-short opened this issue Oct 12, 2021 · 1 comment
Open

Setting Timezone adds an extra hour #1664

mr-short opened this issue Oct 12, 2021 · 1 comment

Comments

@mr-short
Copy link

mr-short commented Oct 12, 2021

Describe the bug
There seems to be an extra hour being added when setting timezones:

dayjs.utc('2021-01-01').toString()                                 // 'Fri, 01 Jan 2021 00:00:00 GMT'
dayjs.utc('2021-01-01').tz('America/Chicago').toString()           // 'Fri, 01 Jan 2021 01:00:00 GMT'
dayjs.utc('2021-01-01').tz('America/Chicago', false).toString()    // 'Fri, 01 Jan 2021 01:00:00 GMT'
dayjs.utc('2021-01-01').tz('America/Chicago', true).toString()     // 'Fri, 01 Jan 2021 07:00:00 GMT'  should be 06

Seems to be related to daylight savings time, as it only appears half the year:

dayjs.utc('2021-01-01').tz('America/Chicago')
                       .tz('America/Chicago')
                       .tz('America/Chicago')
                       .tz('America/Chicago').toString()           // 'Fri, 01 Jan 2021 04:00:00 GMT'
dayjs.utc('2021-07-01').tz('America/Chicago')
                       .tz('America/Chicago')
                       .tz('America/Chicago')
                       .tz('America/Chicago').toString()           // 'Thu, 01 Jul 2021 00:00:00 GMT'

Expected behavior

That it works like momentjs:

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'

Information

  • Day.js Version [v1.10.7, from day.js.org]
  • OS: [Linux/Ubuntu]
  • Browser [Chrome Version 94.0.4606.81 (Official Build) (64-bit)]
  • Time zone: [GMT-06:00 DST (Central Daylight Time)]
@mr-short
Copy link
Author

Looks like there's a PR that has been out for awhile that fixes this issue: #1448

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

1 participant