Search code examples
timeformatstandardsiso8601

Can ISO 8601 represent time intervals where start/end is a duration?


ISO 8601:2004 defines a time interval format which can be expressed in various formats, including "c) by a start and a duration" and "d) by a duration and an end".

Going by the Wikipedia article alone, it seems like the examples only provide for start and end to be "time points", e.g. 2007-03-01T13:00:00Z/P1Y2M10DT2H30M would be a time interval of 1 year, 2 months, 10 days, 2 hours and 3 minutes starting on 2007-03-01 13:00 UTC.

Is it possible to represent a time interval which start or ends after some duration? For example, P1Y/P1Y2M10DT2H30M would be the same duration but "starting" after 1 year.

Such syntax would be useful to model relative time intervals, especially when combined with repeating qualifies. For example, a monthly retirement payout could reasonably be expressed as R/P65Y/1M.


Solution

  • The expression "P1Y/P1Y2M10DT2H30M" is not defined in ISO-8601. This paper mentions following four variants of a "time interval":

    a) Start and end are defined as points in time, example => 2019-08-27/2019-08-29

    b) Duration without any fixed anchor on the (date)- or timeline, example => P3D

    c) Start as point in time and a duration, example => 2019-08-27/P3D

    d) A duration and the end as point in time, example => P3D/2019-08-29

    So your question "Is it possible to represent a time interval which start or ends after some duration?" can be answered by a clear "No". And honestly said, a double duration expression will confuse most users.