Skip Menu |

This queue is for tickets about the TimeDate CPAN distribution.

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

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

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



Subject: 0000-00-00 00:00:00 fails in scalar context but strptime parses?
I'm not sure what I'm expecting the output to be, but when using str2time or strptime just as a simple check for 'properly formatted' both fail. It seems that str2time should at least return something like -1 in a case like this. #!/usr/bin/perl; use strict; use warnings; use Test::Most qw{no_plan}; use Date::Parse; my $z = '0000-00-00 00:00:00'; ok(str2time($z)); # FAILS is(str2time($z),undef); ok(strptime($z)); # FAILS is(strptime($z),undef); eq_or_diff ( [strptime($z)], [qw{00 00 00 00 -1 0000}, undef] ) -- benh~
Subject: Re: [rt.cpan.org #39518] 0000-00-00 00:00:00 fails in scalar context but strptime parses?
Date: Mon, 22 Sep 2008 15:10:54 -0500
To: bug-TimeDate [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Sep 22, 2008, at 1:28 PM, ben hengst via RT wrote: Show quoted text
> I'm not sure what I'm expecting the output to be, but when using > str2time or strptime just as a simple check for 'properly formatted' > both fail. It seems that str2time should at least return something > like > -1 in a case like this.
I am not sure what you are defining as fail. You are passing a date that cannot be represented, so str2time will return undef and strptime will return an empty list. Your ok() is placing strptime into a scalar context, so the empty list becomes undef. -1 is a valid result for str2time, it represents 1969-12-31 23:59:59 GMT Graham.
Subject: Re: [rt.cpan.org #39518] 0000-00-00 00:00:00 fails in scalar context but strptime parses?
Date: Mon, 22 Sep 2008 15:10:54 -0500
To: bug-TimeDate [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Sep 22, 2008, at 1:28 PM, ben hengst via RT wrote: Show quoted text
> I'm not sure what I'm expecting the output to be, but when using > str2time or strptime just as a simple check for 'properly formatted' > both fail. It seems that str2time should at least return something > like > -1 in a case like this.
I am not sure what you are defining as fail. You are passing a date that cannot be represented, so str2time will return undef and strptime will return an empty list. Your ok() is placing strptime into a scalar context, so the empty list becomes undef. -1 is a valid result for str2time, it represents 1969-12-31 23:59:59 GMT Graham.
On Mon Sep 22 16:41:41 2008, gbarr@pobox.com wrote: Show quoted text
> On Sep 22, 2008, at 1:28 PM, ben hengst via RT wrote:
> > I'm not sure what I'm expecting the output to be, but when using > > str2time or strptime just as a simple check for 'properly formatted' > > both fail. It seems that str2time should at least return something > > like > > -1 in a case like this.
> > I am not sure what you are defining as fail. You are passing a date > that cannot be represented, so str2time will return undef and strptime > will return an empty list. Your ok() is placing strptime into a scalar > context, so the empty list becomes undef. > > -1 is a valid result for str2time, it represents 1969-12-31 23:59:59 GMT >
good point about -1, though if we are going to state that 1969-12-31 23:59:59 GMT is valid (result -1) then by the same token 0000-00-00 00:00:00 is just as valid result(-some huge number of seconds) Show quoted text
> Graham. >
-- -- benh~