Skip Menu |
Report information
Id: 127005
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: zefram [at] fysh.org
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] DateTime.Str bad second rounding
Date: Wed, 23 Dec 2015 22:41:47 +0000
From: Zefram <zefram [...] fysh.org>
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 864b
Internally DateTime allows its seconds value to be any kind of numeric value in the right range, but when producing Str output in ISO 8601 format it limits the displayed seconds value to integral microseconds. It attempts to round accordingly, but it screws up by only rounding the seconds value in isolation: Show quoted text
> DateTime.new(:year(2000), :second(59.9999999)).Str
2000-01-01T00:00:60.000000Z It produces invalid output like this whenever rounding up in the last microsecond of a minute. (If there's a leap second, :second(60.9999999) is rounded to ":61.000000".) The rounding ought to instead wrap the seconds value and be carried to the minutes value, and to the hours if the minutes wrap, and so on. Or from another point of view, one should round the DateTime value, and then express the rounded DateTime exactly, rather than round the expression. -zefram


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org