Skip Menu | will be shut down on March 1st, 2021.

This queue is for tickets about the TimeDate CPAN distribution.

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

Owner: Nobody in particular
Requestors: lpsolit [...]

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 [...]
From: "Frédéric Buclin" <lpsolit [...]>
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 infrastructure.

Please report any issues with to