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

Handling of zonedTimeToUtc when zoned time is during daylight saving jump forward is 1 hour too early #222

Open
mcshaz opened this issue Jan 12, 2023 · 1 comment

Comments

@mcshaz
Copy link
Contributor

mcshaz commented Jan 12, 2023

if you look at the diff for pull request #220 (tests only, all currently passing), you can see the current behaviour of zonedTimeToUtc when the time is set to a zoned time which doesn't exist (because the clock jumps forward and skips that hour)

 it('handles times that dont exist with clock jump forward: -ve UTC offset', function () {
      // at 02:00 local clock will immediately jump forward to 03:00
      var result = zonedTimeToUtc('2023-03-12T02:00:00', 'America/New_York')
      // UTC 06:59 is NY 01:59 GMT -5
      // UTC 07:00 is NY 03:00 GMT -4
      // !! this is an error - should either throw error OR return UTC 07:00
      // it should NOT return 06:00 but defining problem before making tests fail
      assert.deepEqual(result.toISOString(), '2023-03-12T06:00:00.000Z')
 })

as per the comments in the above test - I believe if set to 02:00, returning the UTC time which corresponds to 1 hour prior to moving the clock forward is a mistake, and should either return UTC @ the moment the clock had ticked over from 01:59 or throw an error.

@mcshaz mcshaz changed the title Handling of Handling of zonedTimeToUtc when zoned time is during daylight saving jump forward is 1 hour before Jan 12, 2023
@mcshaz mcshaz changed the title Handling of zonedTimeToUtc when zoned time is during daylight saving jump forward is 1 hour before Handling of zonedTimeToUtc when zoned time is during daylight saving jump forward is 1 hour too early Jan 12, 2023
@mcshaz
Copy link
Contributor Author

mcshaz commented Jan 16, 2023

I have a workaround written in typescript in another library. Putting the link here in case someone is having a similar problem. https://github.com/mcshaz/caldate/blob/named-exports/src/zonedTimeToUtc.ts

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