Search code examples
datetimetimezonedstdurationiso8601

Duration in days over DST boundary or across timezones


I'm wondering if ISO-8601 or any other popular standards about time address the issue of duration in days when the interval spans across a DST boundary?

For example, duration in days between 2017-03-01T12:00:00-05:00 and 2017-03-02T12:00:00-05:00 is clearly 1 day.

But what about duration in days between 2017-03-11T12:00:00-05:00 (DST off) and 2017-03-12T12:00:00-04:00 (DST on)? On one hand, it's noon until noon the next day -- which seems like 1 day. On the other hand, it is only 23 hours of actual elapsed time.

Furthermore, whatever the semantics are, would they also apply across different geographic timezones (say noon one day in NYC vs. noon the next day in London)?


Solution

  • Relevant parts of ISO 8601:2004(E)

    2.2.6
    calendar day
    time interval starting at midnight and ending at the next midnight, the latter being also the starting instant of the next calendar day

    NOTE 1 A calendar day is often also referred to as day

    NOTE 2 The duration of a calendar day is 24 hours; except if modified by:

    • the insertion or deletion of leap seconds, by decision of the International Earth Rotation Service (IERS), or
    • the insertion or deletion of other time intervals, as may be prescribed by local authorities to alter the time scale of local time.

    2.2.7
    day
    〈duration〉 duration of a calendar day

    NOTE The term "day" applies also to the duration of any time interval which starts at a certain time of day at a certain calendar day and ends at the same time of day at the next calendar day

    ...

    4.2.2.1

    ... no provisions have been made to prevent ambiguities in expressions that result from discontinuities in the time scale of local time (e.g. daylight saving time)

    In summary, one should be very careful with the term "day". Though the common "standard day" is 24 hours in duration, both leap seconds and local time zone transitions can affect its duration.

    As a rule of thumb, I tend to think about a day in terms of calendar units by default. That is, like month and year, it is part of a calendar system, not a timekeeping system. Think of the those three parts working in unison to produce a square below:

    calendar

    Conversely, units of time are all based on the SI second, which is exactly:

    the duration of 9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium 133 atom

    Our other time units are all derived from there. 60 seconds make a minute. 60 mintues make an hour.

    Though we would prefer to define days in terms of an exact amount of time, we cannot always reconcile the two because of time zones, daylight saving time, and leap seconds.