This is similar to the subset followed by W3C.
Recently, we ran into the specific issue that
fromisoformat() rejects inputs
where the timezone is specified as
+hhmm instead of
Both are allowed by ISO 8601, but only the latter is part of the restricted subset.
Following the Robustness principle (also known as Postel’s law) in the design of our APIs, we would prefer to
Be liberal in what you accept, and conservative in what you send.
Fortunately, the dateutil package’s
parser.isoparse() is able to parse a
broader subset of the standard.
Based on this and the bug report linked above, consider the following guideline:
Default to formatting Python timestamps with
datetime.isoformat(), but parse incoming timestamps with