Regarding the ISO-8601 format:
I'm quoting from ISO-8601:2000 final draft, which is not the latest version, so some of this might be outdated.
I believe the "P" prefix should not be there for Duration
. The "P" prefix is used when a duration is part of a "time interval", but is not part of the "duration" itself:
Time-interval: a portion of time between two time-points. These time-points are respectively labelled âstartâ and âendâ. Time intervals may be specified by these two time-points, by one of these time-points and the temporal distance between the points or by the temporal distance between these points only. [...]
Duration: a quantity (âlengthâ) of time. [...]
In basic and extended format the complete representation for duration shall be nYnMnDTnHnMnS or nW. [...]
A time interval is expressed according to the following rules: [...]
b) for 5.5.1 b), c) and d) the designator [P] shall precede, without spaces, the representation of the duration
So a duration of 5 seconds would be T5S
, not PT5S
.
It's OK to assume days have exactly 24 hours, because ISO-8601 is agnostic about the time standard -- it doesn't have to be UTC or anything:
This International Standard does not assign any particular meaning or interpretation to any data element that uses representations in accordance with this International Standard. Such meaning will be determined by the context of the application. [...]
day: a time-unit of 24 hours
It's even allowed to assume that a month has 30 days!
month: unit of time of 28, 29, 30 or 31 days
NOTE In certain applications a month is regarded as a unit of time of 30 days.
year: a time-unit of 12 months, considered to approximate the duration required for one revolution of the earth around the sun
Display
probably shouldn't use months and years, but FromStr
could assume that months are 30 days are years are 12*30 = 360 days (hmm...). Or it could just reject months and years as ambiguous.
For fractions of a second, commas or periods are allowed, but commas are preferred. So if Duration
were to use ISO-8601
, maybe it should use a comma in Display
?
If necessary for a particular application a decimal fraction of hour, minute or second may be included. If a decimal fraction is included, lower order components (if any) shall be omitted and the decimal fraction shall be divided from the integer part by the decimal sign specified in ISO 31-0: i.e. the comma [,] or full stop [.]. Of these, the comma is the preferred sign.