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 conversion issue, (goes wrong direction) #284

Closed
jisaacks opened this issue Apr 27, 2021 · 4 comments
Closed

Timezone conversion issue, (goes wrong direction) #284

jisaacks opened this issue Apr 27, 2021 · 4 comments
Labels

Comments

@jisaacks
Copy link

Here is an example:

const z = 'America/New_York'
const a = spacetime('03/14/2021, 1:59 AM', z) // The last minute of the timezone
const b = spacetime('03/14/2021, 2:00 AM', z)

// This is correct.
a.format('iso')
// got: "2021-03-14T01:59:00.000-05:00"

// This is also correct
a.add(1, 'minute').format('iso')
// got: "2021-03-14T03:00:00.000-04:00"

// this is wrong
b.format('iso')
// got: "2021-03-14T01:00:00.000-05:00"
// expecting "2021-03-14T03:00:00.000-04:00"

The hour is subtracted (goes from 2 to 1 during the time change) but it should be added (go from 2 to 3)

@spencermountain
Copy link
Owner

hey @jisaacks thanks for the issue.
My gut says it's another example of #235 - this is a tricky case where using native js Date objects for the calculation - it's a chicken and the egg issue. I'll check it out today, to confirm
I've got a fix for this, and hope to release it sometime in may, but no promises.
cheers

@jisaacks
Copy link
Author

Great thanks, I am subscribed to that one too.

Also thanks so much for this library I been wanting something like this for years.

I actually built my own (eerily similar) but it relied on Intl, don't understand how you did it without it!

@spencermountain
Copy link
Owner

spencermountain commented Apr 29, 2021

haha, thanks. I have woken up in the night thinking 'wait, how-the...'
Like, there may be a conceptual reason why this should not work, and I just haven't realized it yet.
Been hoping the temporal folks just solve-everything and we can just go to the beach.

ok, since you seem like the worlds-best githubber, let me try to bait you to help -

Here is an early attempt to formalize the '2nd sunday of march' folk-patterns.

  • The EU does last Sunday in March
  • Mexico does First Sunday in April

I've looked pretty hard, and I don't believe anybody has formalized this before. It's crazy. This website kinda goes through them.
If we could write a function guessDstDate(iana, year) that returned an epoch, it would fix 235, and avoid having to republish new dst dates every year.

Let me know!
cheers

@spencermountain
Copy link
Owner

merging with #235 ->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants