Hi
Am 2026-06-18 15:47, schrieb Tim Düsterhus:
All that said, you can find the RFC at:
https://wiki.php.net/rfc/duration_class. It hopefully includes all the
important explanation and also provides a rationale as to why we made
the design decisions we made.
Derick and I had a first discussion about the feedback so far and I have
made the following changes to the RFC earlier today.
1. Derick looked up the official name of the `PT30M` format in ISO-8601.
It's called “Duration”. We have thus renamed the ->fromIso8601String()
method to ->fromIso8601DurationString(), given the discussion in this
subthread: https://news-web.php.net/php.internals/131409
2. We added an `->absolute()` method to return a non-negative Duration
object with the same magnitude.
3. We limited the duration to 9223372035999999999 nanoseconds in order
to enable a possible future `->getTotalNanoseconds()` method if / when
PHP is not limited to 32-bit integers. This is sufficient to represent a
duration of 292 years, which matches the range of Golang and hopefully
should be plenty. As with any other restriction: It's always possible to
lift it later if it turns out that the future scope will not actually be
relevant and if it causes issues.
4. Tying into (3), but also a pre-existing issue when using
`::fromHours(PHP_INT_MAX)`: We defined that overflowing the allowed
range will result in a Time\TimeException instead of using saturating
math (i.e. clamping to the maximum).
5. And to enable (4) we added the Time\TimeException base exception for
the Time namespace. Additional child exceptions are planned when adding
more classes to the “new date and time API”, but for now we didn't want
to decide on whether:
DurationOverflowException extends DurationException extends
TimeException extends Exception
or
DurationOverflowException extends OverflowException extends
TimeException extends Exception
would be the correct choice (i.e. if we should group by “component” or
by “type of Exception”).
--------------
There are some more things where we haven't yet made a decision. I'll
follow up on those later.
Best regards
Tim Düsterhus