Skip Menu |
 

This queue is for tickets about the TimeDate CPAN distribution.

Report information
The Basics
Id: 48164
Status: resolved
Priority: 0/
Queue: TimeDate

People
Owner: Nobody in particular
Requestors: lpsolit [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Date::Parse unable to set seconds correctly?
Date: Fri, 24 Jul 2009 16:54:26 +0200
To: bug-TimeDate [...] rt.cpan.org
From: "Frédéric Buclin" <lpsolit [...] gmail.com>
Download (untitled) / with headers
text/plain 640b
While debugging Bugzilla, I found something weird with Date::Parse::strptime() version 2.27. # perl -MDate::Parse -we 'my @a = strptime("2008.11.30 22:35 CET"); print join(":", @a);' It returns: 0:35:22:30:10:108:3600. But if you write: perl -MDate::Parse -we 'my @a = strptime("2008-11-30 22:35 CET"); print join(":", @a);' It returns: Use of uninitialized value $a[0] in join or string at -e line 1. :35:22:30:10:108:3600 Note that seconds are undefined in this last case, despite the date is basically the same (I only replaced dots by dashes). This triggers crashes in places where no undefined values are expected.
Download (untitled) / with headers
text/plain 278b
Undefined is actually the correct result, so the code that does not expect them needs to be fixed. strptime will return undef for any value that it cannot extract, and in the strings you gave no seconds were specified. The fix will be to make both your examples return undef


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.