[Pitch] Clock, Instant, Date, and Duration

I finally articulated this morning why I've got an issue with the proposed Duration, thanks to your post @Tino:

The unit is ambiguous.

There are two kinds of durations we deal with: physical seconds and clock seconds. Most of the time these are equivalent, but they do not have to be.

Past Clocks

A bunch of historical clocks had variable length seconds, because the length of a second was derived based on how much daylight there was that day. So if anyone wanted to implement a historical clock for a game or other emulator, what is their Duration value?

Present Clocks

An NTPClock might have a Duration value that is slightly different from a MonotonicClock, if the NTP server chooses to smear leap seconds over the course of a day, instead of injecting a :60 second at the end of the day. This means that the length of an NTPClock's second is slightly longer (by 1/86400th of a physical second) than a MonotonicClock's second. (This also means that applying a Duration by an Instant needs to happen at the Clock level and not the Instant level, because the physical length of a Duration changes depending on the properties of the Clock)

Future Clocks

You mentioned Mars and dismissed it, but I think it's worthy of consideration (especially since we're considering an instantaneous type with hundreds of billions of years of range at nanosecond [or finer] precision). Martian days are about 39 and a half minutes longer than Earth days, and most attempts at martian timekeeping take the approach similar to the NTP clock by smearing the 39 minutes over the 24 hours. This, in effect, is equivalent to saying that "1 second on a martian clock is equivalent to 1.027 seconds on a terrestrial clock".


So... what is Duration measuring? If it's measuring physical seconds, then there needs to be more work to consider what it means to apply a physical second duration to clock-specific instants. If it's measuring clock-specific seconds, then there needs to be more work to consider how to translate "equivalent" durations between clocks.

8 Likes