[Issue 24704] DateTime.fromISOExtString Does Not Support ISO8601 Time Unit Fractions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 16 07:07:16 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24704

Vijay Nayar <madric at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

--- Comment #9 from Vijay Nayar <madric at gmail.com> ---
I think the error message should be altered to prevent confusion in the future.
Currently it states:

> Invalid ISO Extended String: 08:13:23.000

This message gives the impression that DateTime is supporting the full ISO
Extended String standard.

One can also reproduce the error by having a fraction on the minute unit:

> Invalid ISO Extended String: 08:13.000

Regardless of whether DateTime is meant to use second or millisecond
resolution, `fromISOExtString` claims to support ISO Ext Strings. The ISO
standard doesn't change simply because of an implementation detail of DateTime.

Because the ISO standard does not control the number of decimal digits that the
fraction can have, in fact, every implementation will not be able to fully
represent a valid ISO string, but they continue to accept the ISO standard,
extracting as much information as they can.

For example, a utility that only supports millisecond resolution would still be
able to parse an ISO string of "2024-08-15T08:13:25.123456789", only it will
only support saving a value equivalent to "2024-08-15T08:13:25.123".

In my opinion, there are still two issues remaining:
1. Valid ISO Strings within the capabilities of `DateTime` are being rejected,
e.g. "2024-08-15T08:13.5".
2. Valid ISO Strings beyond the resolution of `DateTime`, like
"2024-08-15T08:13:25.123", should either be parsed to include as much
information as they can, or the error message should be clarified rather than
claiming that the string is not ISO.

--


More information about the Digitalmars-d-bugs mailing list