Hi All

On 22.06.26 16:36, Tim Düsterhus wrote:
Hi

Am 2026-06-22 10:42, schrieb Ilija Tovilo:
The Time\Duration class will also implement internal “comparison handlers”, which means that direct comparisons with operators such as < will work.
While reading this I asked myself why we need a specific Duration class...

What is the difference between

new Time(12, 23, 34.567890);

and

new Duration::fromIso8601String('PT12H23M34.567890S');

Both define a number of hours, minutes etc. The only "difference" is that we came to see a time as starting from a certain point in time. But that is in essence just a convention and the time component of a DateTime just represents the a duration.

Also the "limitation" to 24 hours is a convention (that gets blown away in DST situations. As do the 59 seconds with leapseconds)

If we want to think about an improved way of handling datetimes, why not introduce a Time-class that can later be used in combination with a Date class and a Timezone class to define a point in time (or without the Timezone to define a local DateTime).

After all we can already add more than 24 hours to a DateTimeInterface via `setTime` (see https://3v4l.org/QZnZ2#v) - so there should be no issue with creating Time-objects with more than 24 hours...

Don't get me wrong! I like the idea of a dedicated class that holds a Time-based duration. I just think we do not need a separate "Duration" and later a "Time" class when they both - in essence - hold the same information.

Just my 0.02€

Cheers

Andreas
--
                                                              ,,,
                                                             (o o)
+---------------------------------------------------------ooO-(_)-Ooo-+
| Andreas Heigl                                                       |
| mailto:[email protected]                  N 50°22'59.5" E 08°23'58" |
| https://andreas.heigl.org                                           |
+---------------------------------------------------------------------+
| https://hei.gl/appointmentwithandreas                               |
+---------------------------------------------------------------------+
| GPG-Key: https://hei.gl/keyandreasheiglorg                          |
+---------------------------------------------------------------------+

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to