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

Potential Timestamp Issue #38

Open
mdelez opened this issue Mar 4, 2020 · 1 comment
Open

Potential Timestamp Issue #38

mdelez opened this issue Mar 4, 2020 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@mdelez
Copy link
Contributor

mdelez commented Mar 4, 2020

While working on the Time Value Component (#36), I stumbled across some interesting behavior and I'm wondering if it will have an affect later on with other programming languages.

The potential issue
When submitting time values with a rather old date, the timestamp that is stored looks incorrect but when converted to the local timezone, what the user see's is correct.

For example:
Screen Shot 2020-03-04 at 13 27 33

To clarify this next part, positive offset value are returned as a negative value and in minutes, so our offset from UTC is -120 (or 2 hours ahead).

When I save this value and get the value back I would expect the timestamp to be
"1776-07-04T18:00:00.000Z" accounting for our -120 offset from UTC. However what we get back is
"1776-07-04T19:25:52.000Z" with an offset of -34

When you refresh the page, the time value that is shown to the user is "20:00", again accounting for our -120 offset from UTC, which is correct.

However, if you submit a rather recent date, the timestamp that is stored looks exactly how it should and when it is converted to the local time zone, it is also correct.

For example:
Screen Shot 2020-03-04 at 13 37 33

When I save this value, the timestamp I get back from the value is "2019-07-04T18:00:00.000Z" with an offset of -120 which is exactly what I had entered into the form.

I fully acknowledge that I don't fully understand what this offset magic is doing and why is changes so drastically for older dates but I just wanted to raise the awareness to this because maybe this offset magic is specific to Javascript and other programming languages will struggle with it or maybe it won't be an issue at all :)

@flavens flavens added the question Further information is requested label Mar 10, 2020
@tobiasschweizer
Copy link
Contributor

I think the magic comes from the JS Date object.

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

No branches or pull requests

3 participants