https://issues.dlang.org/show_bug.cgi?id=24704
Issue ID: 24704
Summary: DateTime.fromISOExtString Does Not Support ISO8601
Time Unit Fractions
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: [email protected]
Reporter: [email protected]
## Summary
When parsing ISO8601 date-times using DateTime.fromISOExtString, the fraction
component of the last time unit causes an exception to be thrown.
## Context
The method
https://dlang.org/phobos/std_datetime_date.html#.DateTime.fromISOExtString is
built to support the ISO8601 standard:
https://en.wikipedia.org/wiki/ISO_8601#Times
According to this standard:
> A decimal fraction may be added to the lowest order time element present in
> any of these representations. A decimal mark, either a comma or a dot on the
> baseline, is used as a separator between the time element and its fraction.
> (Following ISO 80000-1 according to ISO 8601:1-2019,[27] it does not
> stipulate a preference except within International Standards, but with a
> preference for a comma according to ISO 8601:2004.[28]) For example, to
> denote "14 hours, 30 and one half minutes", do not include a seconds figure;
> represent it as "14:30,5", "T1430,5", "14:30.5", or "T1430.5".
>
> There is no limit on the number of decimal places for the decimal fraction.
> However, the number of decimal places needs to be agreed to by the
> communicating parties. For example, in Microsoft SQL Server, the precision of
> a decimal fraction is 3 for a DATETIME, i.e., "yyyy-mm-ddThh:mm:ss[.mmm]".[29]
## Steps To Reproduce the Problem
Create the following program:
```
void main()
{
import std.datetime;
auto b = DateTime.fromISOExtString("2024-08-15T08:13:23.000");
}
```
## Expected Results
The date-time should be parsed, with the fraction being interpreted as a
fraction of the seconds unit.
## Actual Results
An exception is thrown of the form:
```
core.time.TimeException@/dlang/dmd/linux/bin64/../../src/phobos/std/datetime/date.d(9334):
Invalid ISO Extended String: 08:13:23.000
----------------
/dlang/dmd/linux/bin64/../../src/phobos/std/datetime/date.d:9334 pure @safe
std.datetime.date.TimeOfDay
std.datetime.date.TimeOfDay.fromISOExtString!(immutable(char)[]).fromISOExtString(scope
const(immutable(char)[])) [0x5626aa88fea9]
/dlang/dmd/linux/bin64/../../src/phobos/std/datetime/date.d:3271 pure @safe
std.datetime.date.DateTime
std.datetime.date.DateTime.fromISOExtString!(immutable(char)[]).fromISOExtString(scope
const(immutable(char)[])) [0x5626aa87f85e]
./onlineapp.d:7 _Dmain [0x5626aa87ebc7]
```
--