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

DateRule setting time to 00:00:00 results in off-by-one errors #28

Closed
graste opened this issue Oct 25, 2016 · 0 comments
Closed

DateRule setting time to 00:00:00 results in off-by-one errors #28

graste opened this issue Oct 25, 2016 · 0 comments
Labels

Comments

@graste
Copy link
Member

graste commented Oct 25, 2016

This behaviour breaks expectations when one is not thinking about this. Example:

System is using UTC. PHP script sets default timezone to CET (+01:00). ValueHolder sets value as follows:

date_default_timezone_set('Europe/Berlin');
$value = $date_attribute->createValueHolder();
$value->setValue('2016-12-10');

This input is treated as follows in DateRule:

  • create DateTimeImmutable as 2016-12-10T00:00:00.000000+01:00
  • force internal timezone to UTC: 2016-12-09T23:00:00.000000+00:00
  • recreate as 2016-12-09T23:00:00.000000+00:00
  • set time to 00:00:00 resulting in 2016-12-09T00:00:00.000000+00:00

This means we now have a date set internally that is off by one. 🎱

Suggested solution: don't set the time info at all or make it optional.

@graste graste added the bug label Oct 25, 2016
graste added a commit that referenced this issue Oct 26, 2016
this leads to wrong interpretation of dates (off-by-one) as the time is
changed. The native format used still contains the time information to
provide the timezone information for consumers. A short format like
'yyyy-MM-dd+00:00' is not being used even though php likes it other
parties interpreting that value might not like it. One example are api
consumers that get that native value or even elasticsearch which wants to
see something like "yyyy-MM-ddT+00:00". That would be parsed as military
Tango time though by php. That's why we sent the time info. Meh.
Suggestions are welcome. Applications can reformat according to their
needs on their system boundaries.

Future improvement suggestion: internally store the timezone of the given
values to have them available later on. This helps in migrating stuff when
eg.g the timezone db changes.

refs #28
@graste graste closed this as completed Nov 28, 2019
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

1 participant