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

Occasional off-by-one error when storing date #3907

Closed
ebruchez opened this Issue Jan 24, 2019 · 5 comments

Comments

Projects
1 participant
@ebruchez
Copy link
Collaborator

ebruchez commented Jan 24, 2019

+1 from customer

Says it happens with date and date/time. We haven't reproduced this so far. It might depend on the various timezone settings: browser, JVM.

@ebruchez ebruchez self-assigned this Jan 24, 2019

@ebruchez ebruchez changed the title Possible off-by-one error when storing date Occasional off-by-one error when storing date Jan 24, 2019

@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

ebruchez commented Jan 24, 2019

This is probably the case only with the new date component.

@ebruchez ebruchez added this to To review in Orbeon Forms 2019.1 Jan 30, 2019

@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

ebruchez commented Feb 4, 2019

Findings:

  • user is on 2018.2.201812312321 PE (with custom persistence API)
  • user has browser and server in CET timezone and tries for example at around 6:50 am
    • current-dateTime()2019-01-17T06:49:39.793+01:00
  • incorrect value appears stored into the data directly (no calculations)
  • happens with dd.mm.yyyy format (possibly all formats)
  • scenario
    • original stored value is 2032-05-29T10:00:00
    • user picks for example 28.5.2032 in date/time
    • Ajax sends 2032-05-28 for date component (correct)
    • unknown yet what Ajax response says
    • upon blur/focus, later value 2032-05-27 is sent by client
@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

ebruchez commented Feb 6, 2019

It seems confirmed that the error happens on the client.

I notice that we use the datepicker's setDate and getDate, where:

date is assumed to be a “local” date object, and will be converted to UTC for internal use

I don't like this conversion. That might explain why things depend on the local timezone!

So I am switching to setUTCDate and getUTCDate instead.

@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

ebruchez commented Feb 6, 2019

I reproduce the issue by changing my computer's timezone to CET. Chrome changes its timezone immediately as well based on new Date().

@ebruchez ebruchez closed this in 7479258 Feb 6, 2019

Orbeon Forms 2019.1 automation moved this from To review to Done Feb 6, 2019

Orbeon Forms 2018.2.1 automation moved this from To do to Done Feb 6, 2019

@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

ebruchez commented Feb 6, 2019

For reference, we did not need to switch to setUTCDate/getUTCDate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment