Thread overview
[Issue 8646] New: std.datetime ISO strings are incompatible with ISO 8601
Sep 12, 2012
Jonathan M Davis
Sep 12, 2012
Jonathan M Davis
September 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8646

           Summary: std.datetime ISO strings are incompatible with ISO
                    8601
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: jens.k.mueller@gmx.de


--- Comment #0 from jens.k.mueller@gmx.de 2012-09-12 10:03:23 PDT ---
According to http://en.wikipedia.org/wiki/ISO_8601 ISO 8601 date time strings contain nothing below seconds. But the std.datetime's ISO function contain values for this. Hence, it is currently incompatible with ISO 8601.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8646


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jmdavisProg@gmx.com
         Resolution|                            |INVALID


--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-09-12 10:38:22 PDT ---
It's perfectly legit. Reread the Times section. You can have "decimal fractions" (which is a really screwed up term IMHO, since decimals and fractions are different things, but whatever) to any of the three time elements - including seconds. The number of decimal places to use "needs to be agreed to by the communicating parties," but the notation is correct. If there's a problem, it's the fact that fromISOExtString doesn't accept variants of ISO-8601 that toISOExtString doesn't use (e.g. using a comma instead of a decimal or having decimal fractions for minutes). But they both follow the standard.

There are other places online that fractional seconds are discussed as well. e.g. http://www.cl.cam.ac.uk/~mgk25/iso-time.html

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8646



--- Comment #2 from jens.k.mueller@gmx.de 2012-09-12 12:42:16 PDT ---
Thanks for your prompt reply. I see now that the standard allows for fractional seconds. In my use case I'm programming against against a specification that demands ISO 8601 conformity without fractional seconds. Is there an easy way to remove the fractional seconds? Because if there are no then toISOExtString() won't return them. My current workaround is quite tedious for this common operation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8646



--- Comment #3 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-09-12 13:30:04 PDT ---
Just strip the fractional seconds from the SysTime by setting its fracSec property to 0. So, something like

sysTime.fracSec = FracSec.from!"msecs"(0);

(I should probably add a static property to FracSec which gives you 0, but there isn't anything like that right now). Then when you call toISOString or toISOExtString, it doesn't have any fractional seconds, so the resultant string won't have them.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8646



--- Comment #4 from jens.k.mueller@gmx.de 2012-09-12 13:49:21 PDT ---
Thanks. This looks good.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------