IJMacD/rfc3339-iso8601

ISO8601 durations: apparently it's not valid to combine weeks combined with other units

Closed this issue · 2 comments

Thanks for the comparison tables and the compatibility visualization - they're both extremely useful.

I'm writing with a note about ISO 8601 durations -- and in particular measurements in units of weeks (like P1W).

Apparently weeks can only appear in a duration string if they're the only measurement unit present. Quoting the formats listed on the relevant Wikipedia page:

PnYnMnDTnHnMnS
PnW
PT

In practice I'm sure many parsers ignore this limitation -- but strictly speaking, it seems to be the case. There are a couple of entries in the example formats table that might need updating.

Hey thanks for bring this up Jay.

You are indeed correct. The week designator in duration representations may only be used on its own. (Relevant section §5.5.2.2) However it is permitted to use decimal fractions (§5.5.2.3 b) and omit the T when unambiguous (§5.5.2.3 c) so I'll update the table.

It's worth noting the last format you mentioned (P<date>T<time>) is only permitted with mutual agreement. (§5.5.2.4)

Thank you @IJMacD!