IJMacD / rfc3339-iso8601

https://ijmacd.github.io/rfc3339-iso8601
301 stars 11 forks source link

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

Closed jayaddison closed 1 year ago

jayaddison commented 1 year ago

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.

IJMacD commented 1 year ago

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)

jayaddison commented 1 year ago

Thank you @IJMacD!