Re: [RFC] Duration class
| From: | Paweł Kraśnicki | Date: | Mon, 22 Jun 2026 18:52:13 +0000 |
| Subject: | Re: [RFC] Duration class | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131478@lists.php.net to get a copy of this message | ||
Hello,
On Mon, 22 Jun 2026 at 09:42, <marc@mabe.berlin> wrote:
> I have looked up the implementations of other Duration classes you mentioned - Go, Java, Rust -
> none of them have such kind of negative flag.
For reference, brick/date-time's Duration class also allows seconds to
be negative instead of storing a separate flag:
https://github.com/brick/date-time/blob/8a41dbf7c7a63b21fa511dfcb3794a50d2a3dbaa/src/Duration.php
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.
Best regards,
Paul