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

Owner: Nobody
Requestors: zefram [at]

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

Subject: [BUG] bad DateTime.Str output for non-minute timezones
From: Zefram <zefram [...]>
Date: Wed, 23 Dec 2015 22:57:39 +0000
To: rakudobug [...]
Download (untitled) / with headers
text/plain 1.6k
Show quoted text
> my $a =, :hour(13), :timezone(3600)); $a.Str
2000-01-01T13:00:00+01:00 Show quoted text
>$a.Instant, :timezone(3630)).Str
DateTime formatter: offset 3630 not divisible by 60 in block <unit> at <unknown file>:1 2000-01-01T13:00:30+01:00 These two DateTime objects obviously represent the same point in time, but they are being converted to ISO 8601 format as if they represent different times, 30 seconds apart. As the warning message alludes to, ISO 8601 doesn't permit a seconds component in the zone offset, so there is a problem in representing the zone offset. But that doesn't prevent the point in time being represented correctly. To deal with non-minute timezones, you have a choice of three not-entirely-satisfactory options. Firstly, you could round the zone offset (which you are almost doing) and adjust the represented local time accordingly (which you are not doing), so the 3630 conversion above would yield either "2000-01-01T13:00:00+01:00" or "2000-01-01T13:01:00+01:01". Secondly, you could use the obvious extension of the ISO 8601 format to a seconds component, outputting "2000-01-01T13:00:30+01:00:30". Or finally you could signal an error (not just a warning) when trying to represent a zone offset that's not an integral minute. Incidentally, for offsets of -1 to -59 inclusive, your truncation of the timezone offset isn't clearing the negative sign, so is producing the invalid output "-00:00". The zero offset is required to be represented with a "+" sign. If you take the rounding option described above, anything that rounds to a zero-minutes offset must yield "+00:00" or "Z" in the output. -zefram

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

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