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

Incorrect DBDate behaviour for years before 100 #9663

Open
sb-relaxt-at opened this issue Aug 27, 2020 · 2 comments
Open

Incorrect DBDate behaviour for years before 100 #9663

sb-relaxt-at opened this issue Aug 27, 2020 · 2 comments

Comments

@sb-relaxt-at
Copy link
Contributor

Affected Version

Framework Version 4, tested on 4.6.0

Description

Constructing certain dates is not working properly with DBDate and DBDatetime.

Steps to Reproduce

$date = new DBDatetime();
$date->setValue(-62135596800);
$date->getValue(); // 1-01-03 00:00:00
$date->rfc2822(); // "2001-01-03 00:00:00"

This is due to this php behaviour:

If the number of the year is specified in a two digit format, the values between 00-69 are mapped to 2000-2069 and 70-99 to 1970-1999.
https://www.php.net/manual/en/function.strtotime.php

Proposed solution

It seems to be sufficient to change DBDate::ISO_DATE to 'yyyy-MM-dd' and the corresponding formats in DBDateTime as well. This should ensure correct four digit rendering (see http://userguide.icu-project.org/formatparse/datetime).

Related issues

This might be related to #9288. And there is another issue when using dates before 1000, see #9133

@robbieaverill
Copy link
Contributor

Thanks for raising this. I see you've referenced the two issues I was going to reference. Do you think this is a different issue to #9133 specifically?

@sb-relaxt-at
Copy link
Contributor Author

I'm quite confident that it is different but not independent from #9133, as in my example I use a timestamp - which is not handled by the function that causes the issue in #9133. I suppose we can fix this issue which will allow correct creation of year 1 and alike by passing a timestamp. But this won't solve the other issue (passing a date string).

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

No branches or pull requests

3 participants