Closed solodkiy closed 3 years ago
Looks like we should or start throw exception on any seconds part start from TimeZoneOffset object, or rewrite ZonedDateTime::of logic to not use \DateTimeZone. First solution looks more reasonable for me.
Good finding! I don't think there is a use case for a time-zone offset with seconds, so I agree that we should throw an exception.
Should we regexp it first, before giving it to DateTimeZone
?
Just read the code again, and if I'm not mistaken, we should deny creating a TimeZoneOffset
with seconds altogether:
TimeZoneOffset
factory methodsIsoParsers::timeZoneOffset()
BTW, I think this should also be brought up on the internals mailing list, as it's a rather big annoyance.
This will be fixed in PHP 8.1: https://bugs.php.net/bug.php?id=81097
Do you think we should throw an exception in earlier PHP versions, when seconds is not zero?
Fixed in 01c7e255575be8dce95d95c57a380c47c360d985. We now prevent seconds altogether in TimeZoneOffset
, so that we're always compatible with DateTimeZone
.
Looks like \DateTimeZone with used in ZonedDateTime::of logic not working correctly with seconds in offset. It silently convert any offset with seconds to UTC timezone.