Hi Paul

I don't think I've seen your name on the list before. If this indeed your first email here: Welcome and thank you for contributing!

Am 2026-06-22 20:52, schrieb Paweł Kraśnicki:
For reference, brick/date-time's Duration class also allows seconds to
be negative instead of storing a separate flag:

Note that brick/date-time is as per the README (very) closely modeled after Java’s implementation, except for necessary differences to fit the API in PHP:

This component follows an important part of the JSR 310 (Date and Time API) specification from Java. Don't expect an exact match of class and method names though, as a number of differences exist for technical or practical reasons.

So taking inspiration from that implementation is effectively taking inspiration from Java’s implementation.

The nanoseconds are always non-negative, so a duration of negative
half a second would be stored as -1 seconds and 500,000,000
nanoseconds.

Yes, this matches Java’s implementation. I've explained in https://news-web.php.net/php.internals/131466, why I don’t consider this representation to be intuitive or easy to use.

Best regards
Tim Düsterhus

Reply via email to