Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 45767
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: mkanat [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.49
Fixed in: 0.52



Subject: DateTime says 59.6 is an invalid value for "seconds"
Run this script: #!/usr/bin/perl -w use strict; use DateTime; print DateTime->VERSION . "\n"; my $dt = DateTime->new({ year => 2009, second => 59.6, }); And DateTime will throw the following error: Invalid second value (59.6) This happens for any fractional second value > 59. It doesn't happen for fractional second values below 59. I'd say that 59.6 is a perfectly valid number of seconds.
On Tue May 05 22:09:47 2009, MKANAT wrote: Show quoted text
> Run this script: > > #!/usr/bin/perl -w > use strict; > use DateTime; > print DateTime->VERSION . "\n"; > my $dt = DateTime->new({ > year => 2009, > second => 59.6, > }); > > And DateTime will throw the following error: > > Invalid second value (59.6) > > This happens for any fractional second value > 59. It doesn't happen for > fractional second values below 59. > > I'd say that 59.6 is a perfectly valid number of seconds.
Actually, it's not, but the real problem is that DateTime isn't being strict enough. All the numbers passed to the constructor should be integers. The 59.x case gets caught simply because any value of seconds Show quoted text
> 59 triggers a special "is this a valid leap second" check.