Re: [RFC] Duration class

From: Date: Sun, 21 Jun 2026 23:07:19 +0000
Subject: Re: [RFC] Duration class
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-131442@lists.php.net to get a copy of this message
On 2026-06-22 01:57, Tim Düsterhus wrote:
Hi Operation-wise I would agree that “div mod” is the correct thing to do, but I don't think that calling Duration/Duration->(int, Duration) literally divmod is an intuitive API when there's also the other division that does Duration/int->Duration. Best regards Tim Düsterhus
Oof. Naming. The only term I can find that is specifically about dividing one duration by another is "beat", but that's definitely domain-specific. 'periodCount' or 'countPeriods' come to mind. Since in 'n/d' we're counting how many times duration 'd' occurs during duration 'n' we're basically multiplying the duration by frequency '1/d'; the inverse of the frequency - 'd' itself - is called the period. Which word is also used for "named subdivision of historical time", "class-sized subdivision of a school day", and so on. The biggest hangup with that name is that it doesn't explicitly state that it returns the remainder as well. periodParts? periodDivide?

« previous php.internals (#131442) next »