Re: [RFC] Duration class
| From: | ignace nyamagana butera | Date: | Sun, 21 Jun 2026 09:18:04 +0000 |
| Subject: | Re: [RFC] Duration class | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131436@lists.php.net to get a copy of this message | ||
Le dim. 21 juin 2026, 01:34, Morgan <weedpacket@varteg.nz> a écrit :
> On 2026-06-21 03:50, ignace nyamagana butera wrote:
> >
> > Hi Tim and Marc
> >
> > I would go with two methods if possible :
> >
> > Duration::countOf(Duration $duration): int; // which would act a bit
> > like intdiv
> > Duration::remainder(Duration $duration): Duration; // which would
> > return the remainder as a Duration instance
> >
> > But that's just a thought.
> >
>
> And BCMath just recently picked up a function to do both of those in a
> single call, since calculating one gives you the other for free and
> frequently users want both.
>
Indeed Duration::divmod is the way forward just wondering about the return
type. Should it be an array or a immutable DTO with .2 properties quotient
and remainder?
Best regards,
Ignace
>