Skip to content

When user timezone is Europe/Lisbon, the tempo's range function throws an "Invalid offset" exception. #59

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

Closed
sashamilenkovic opened this issue Jun 5, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@sashamilenkovic
Copy link

sashamilenkovic commented Jun 5, 2024

Reproduction can be seen on the @formkit/tempo docs itself by editing the range example and passing the token years. Issue occurs when timezone is Europe/Lisbon though I'm sure there are others.

Screenshot 2024-06-05 at 2 23 55 PM

@kswedberg
Copy link

I just started seeing this when I updated FormKit to 1.5.7 and FormKit Pro to 0.126.11, but I'm in America/Detroit timezone.

Can you recommend a version to revert to until this issue is fixed?

@kswedberg
Copy link

To be clear, the error I'm seeing is Invalid offset: -05:32.18333333333334

@kswedberg
Copy link

So sorry for spamming the comments here! I should mentioned that the problem occurs with the following schema:

[
 {
    $formkit: 'datepicker',
    name: 'date',
    format: 'DD-MMM-YYYY',
    valueFormat: 'YYYY-MM-DD',
    validation: 'required',
    overlay: true,
  },
]

@justin-schroeder
Copy link
Member

Wow, this is obscure. It has to do with the really old dates in certain timezones. When we use the YYYY token with range() token, we scan -120 years and + 50 or so. It turns out that some timezones return very odd results for dates in 1904 specifically. For example in America/Detroit if you run:

new Date('1904-06-06T00:00:00')
// 1904-06-06T05:32:11.000Z

where is that 32:11 coming from? Well it turns out that January 1st 1905 the clocks moved from LMT to CST — so the resulting time is actually accurate. Our internal methods were not expecting a timezone offset to have seconds in them. Since these 11 seconds are not particularly important we will round them going forward.

@justin-schroeder
Copy link
Member

@kswedberg this should be fixed in 0.1.2

@kswedberg
Copy link

Thanks so much, @justin-schroeder ! Works like a charm now 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants