Re: [RFC] Duration class
| From: | Andreas Heigl | Date: | Tue, 23 Jun 2026 04:48:15 +0000 |
| Subject: | Re: [RFC] Duration class | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131489@lists.php.net to get a copy of this message | ||
Hi Tim, hey all
On 22.06.26 22:31, Tim Düsterhus wrote:
Attachment: [application/pgp-signature] OpenPGP digital signature OpenPGP_signature.asc
Hi On 6/22/26 17:34, Andreas Heigl wrote:I don't see this as a philosophical question but a question of Naming. To take your example: A meeting is never at 10:00. But at 10:00 on date X at location Y. The 10:00 part is merely one part of a meeting-time. *If* you want philosophical questions (and yes, I believe the internals mailinglist is also the place to tackle these - as uncomfortable as they might be) then I would argue that the "Duration" you have in mind is actually not a duration but merely a ValueObject for SI-Seconds with a nanosecond resolution. After all a duration can also be "5 years". But that is explicitly excluded. Why? After all the second was in 1956 defined as 1/31,556,925.9747th of a year. So from a philosophical point of view: Why should a *duration* only be definable in units that can (more or less relaibly) be converted into seconds? ButI just think we do not need a separate "Duration" and later a "Time" class when they both - in essence - hold the same information.The Internals mailing list is not the correct location to debate philosophical questions. Humans considerDurations andTimes to be different concepts. The difference between “meeting is (in/at) 10:00” is the difference betweenDurationandTime. If you conflate those, you end up being late. Similarly if I callsleep(new Time(0, 10, 0)), I'm expecting the process to sleep until 10 past whatever midnight comes next, not for 10 minutes.
sleep(new Seconds(12, 123456789)) or sleep(Seconds::fromHours(12,34,45,123456789)) sounds like exactly what one expects.
That this Seconds class can then be reused later in an improved DateTime library is only a sidenote.
The idea that Time is midnight-based is but a western european assumption based on the gregorian calendaring system. As long as the reference-point isn't defined, a Time is just a collection of hours, minutes and seconds. Similar to a Money object that is just a collection of numbers and units that is in itself totally value-less as long as you don't add a currency. And in both cases the number of units that make up the next level can be different depending on the reference-point.
*That* is for me a philosophical question.
Anyhow.
It's not a hill I'll die upon.
It's just my 0.02€
Cheers
Andreas
Best regards Tim Düsterhus-- ,,, (o o) +---------------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto:andreas@heigl.org N 50°22'59.5" E 08°23'58" | | https://andreas.heigl.org | +---------------------------------------------------------------------+ | https://hei.gl/appointmentwithandreas | +---------------------------------------------------------------------+ | GPG-Key: https://hei.gl/keyandreasheiglorg | +---------------------------------------------------------------------+
Attachment: [application/pgp-signature] OpenPGP digital signature OpenPGP_signature.asc