-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
ZonedDateTime::of()
issue when year is less than 1892
#44
Comments
Hi, for dates before time zones were invented, the timezonedb tends to observe the local mean time of the place and simply provides the UTC offset of the town's meridian. Consider the database entry for
You can see that until October 1891, the UTC offset was 0:57:44. However, sub-minute offsets have been prohibited in 01c7e25. Perhaps @BenMorel can chime in with the reasoning behind the change? |
@jiripudil Please check #35 for the rationale behind this. Could you please investigate the issue and tell me what you think the best move would be here? I'd happy to revert the commit, but PHP seems to always refuse seconds in offset now: https://3v4l.org/FG6nZ (see the PHP bug in the linked issue) Does that mean that we can't rely on, or have to hack around, |
Thanks for the context! It seems that this issue has been remediated in the fresh out of the oven PHP 8.1.7 by an update of the underlying timelib (php/php-src#8589). Unfortunately, PHP's data structures do not support sub-minute offsets, so I don't know what your stance is on supported PHP versions, but even I would be hesitant to require a version that has just been tagged a few days ago. That being said, I see no reason why developers should be deprived of the feature if they're running a version of PHP that supports it. Perhaps we could only allow sub-minute offsets for |
That sounds good, do you want to open a PR? |
Sure :) |
Following code works well (no output):
while this one throws
Brick\DateTime\DateTimeException: The time zone offset of 3464 seconds is not a multiple of 60
:The only difference is the year passed into
LocalDateTime::of()
. If I tryLocalDateTime::min()
instead, it results in the exception as well.I found out that the border where it stops working is 1891–1892 (which 130 years back from now). Is this some issue with
DateTime
and/or itsgetOffset()
which is used inside of theZonedDateTime::of()
?But it doesn't fail with UTC time zone actually..
The text was updated successfully, but these errors were encountered: