Jump to page: 1 2
Thread overview
[Issue 24704] DateTime.fromISOExtString Does Not Support ISO8601 Time Unit Fractions
[Issue 24704] The error message for DateTime.fromISOExtString says that valid ISO extended strings that it does not support are invalid ISO extended strings
Aug 16
Dlang Bot
Aug 16
Dlang Bot
August 15
https://issues.dlang.org/show_bug.cgi?id=24704

Carsten Schlote <carsten.schlote@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carsten.schlote@gmx.net

--- Comment #1 from Carsten Schlote <carsten.schlote@gmx.net> ---
I remember that I stumbeled about that issue, but I had no time to care about it or report it as bug.

I just examined the code - it converts the string to a TimeOfDay structure, which has noch fractions of a second. So, in a logic consequence, no support for fractions of a second.

So we can either ignore the fractions (no good), or implement the missing bits.

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

--- Comment #2 from Carsten Schlote <carsten.schlote@gmx.net> ---
Added a draft PR for this issue: https://github.com/dlang/phobos/pull/9046

At the moment only the ISOExtString beviour is modified.

We might need some reasoning, if similiar changes schould be applied for the other from/to functions.

Most important, some implementation hacks must cleaned up and replaced by some 'better' solution.

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

Carsten Schlote <carsten.schlote@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
                 OS|Linux                       |All
           Severity|normal                      |minor

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

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #3 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
DateTime is not supposed to support fractional seconds. It's specifically for dealing with calendar operations. SysTime is the time intended for the system time. The documentation is clear on this.

As such, if you have an ISO or ISO extended string which may contain fractional seconds, you should use SysTime's fromISO(Ext)String, not DateTime's.

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

--- Comment #4 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
(In reply to Jonathan M Davis from comment #3)
> As such, if you have an ISO or ISO extended string which may contain fractional seconds, you should use SysTime's fromISO(Ext)String, not DateTime's.

And if for some reason, you really do need a DateTime rather than a SysTime, you can cast the resulting SysTime to a DateTime.

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

--- Comment #5 from Carsten Schlote <carsten.schlote@gmx.net> ---
Good point. So I move my changes to SysTime, if this is the better place for it.

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

--- Comment #6 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
(In reply to Carsten Schlote from comment #5)
> Good point. So I move my changes to SysTime, if this is the better place for it.

SysTime already supports fractional seconds. This already compiles and runs just fine:

---
void main()
{
    import std.datetime;

    auto dt =
cast(DateTime)SysTime.fromISOExtString("2024-08-15T08:13:23.000");

    assert(dt.year == 2024);
    assert(dt.month == 8);
    assert(dt.day == 15);
    assert(dt.hour == 8);
    assert(dt.minute == 13);
    assert(dt.second == 23);
}
---

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

--- Comment #7 from Carsten Schlote <carsten.schlote@gmx.net> ---
Problem can be easily fixed like this:

```
    import std.datetime;

    auto b = SysTime.fromISOExtString("2024-08-15T08:13:23.000");
    assert("2024-Aug-15 08:13:23" == b.toString);
    auto c = SysTime.fromISOExtString("2024-08-15T08:13:23.25");
    assert("2024-Aug-15 08:13:23.25" == c.toString);

    auto d = SysTime(DateTime(2024, 8, 15, 13, 23, 25)).toISOExtString();
    assert("2024-08-15T13:23:25" == d);

    auto e = cast(DateTime)c;
    assert("2024-Aug-15 08:13:23" == e.toString);
```

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

Carsten Schlote <carsten.schlote@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

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

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WONTFIX

--- Comment #8 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
It wasn't actually a bug - just a misunderstanding on how to use the library - so marking it as fixed isn't appropriate (that would result in an entry in the changelog), so I'm changing it to wontfix.

--
« First   ‹ Prev
1 2