Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Time-Local CPAN distribution.

Report information
The Basics
Id: 34736
Status: rejected
Priority: 0/
Queue: Time-Local

People
Owner: Nobody in particular
Requestors: Lars.Danielsen [...] datagraf.dk
Cc:
AdminCc:

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



Subject: Error when month is out of range
Date: Mon, 7 Apr 2008 14:21:34 +0200
To: <bug-Time-Local [...] rt.cpan.org>
From: "Lars Danielsen" <Lars.Danielsen [...] datagraf.dk>
Download image001.gif
image/gif 1.4k
image001.gif
Hello I think I have found a bug in time-local. Pleace consider this code: use strict; use Time::Local; my $int = Time::Local::timelocal_nocheck(59, 59, 23, 31, 11, 100); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $int; print "$year/$mon/$mday $hour:$min:$sec"; #returns 100/11/31 23:59:59, being one second before newyear 2000 print "\n"; my $int = Time::Local::timelocal_nocheck(61, 59, 23, 31, 11, 100); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $int; print "$year/$mon/$mday $hour:$min:$sec"; #returns 101/0/1 0:0:1, being one second after newyear 2001, since seconds are invalid, next year is reached print "\n"; #same thing for minutes, hours and dates, but for months, it does not add a year. The month is apparently set to $mon % 12 somewhere: my $int = Time::Local::timelocal_nocheck(59, 59, 23, 31, 12, 100); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $int; print "$year/$mon/$mday $hour:$min:$sec"; #returns 100/0/31 23:59:59, not 101/0/31 23:59:59 as expected When dec 32. 2000 is parsed as jan 1. 2001, I suppose that [13th month] 1. 2000 should be jan 1. 2001 as well. Wouldn't you agree? Cordially Lars Danielsen Developer Tlf: 87 95 55 55 Direkte: 87 95 55 90 Mobil: 30 20 30 41
Subject: Re: [rt.cpan.org #34736] Error when month is out of range
Date: Mon, 7 Apr 2008 09:22:30 -0500 (CDT)
To: Lars Danielsen via RT <bug-Time-Local [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Mon, 7 Apr 2008, Lars Danielsen via RT wrote: Show quoted text
> When dec 32. 2000 is parsed as jan 1. 2001, I suppose that [13th month] > 1. 2000 should be jan 1. 2001 as well. Wouldn't you agree?
No, I don't agree. The purpose of the nocheck versions is _not_ to do wacky date math, it is simply to offer a faster version when you _already know_ that your data is valid. The docs say this explicitly: If you are working with data you know to be valid, you can speed your code up by using the "nocheck" variants, "timelocal_nocheck()" and "timegm_nocheck()". -dave /*========================== VegGuide.Org Your guide to all that's veg ==========================*/
Subject: SV: [rt.cpan.org #34736] Error when month is out of range
Date: Tue, 8 Apr 2008 08:14:14 +0200
To: <bug-Time-Local [...] rt.cpan.org>
From: "Lars Danielsen" <Lars.Danielsen [...] datagraf.dk>
Hi Dave OK, I see. I use the feature of april 31. returning may 1. when I generate a calendar, in that way I don't need to worry about leap year. But since there is always 12 months in a year, I can do without this feature for months. Another use is to generate a date of "60 days ago" or "4 months from now". In other languages I have used this behaviour of the date object, but I guess that I have to find other ways when doing it in perl. Regards Lars D Show quoted text
-----Oprindelig meddelelse----- Fra: autarch@urth.org via RT [mailto:bug-Time-Local@rt.cpan.org] Sendt: 7. april 2008 16:23 Til: Lars Danielsen Emne: Re: [rt.cpan.org #34736] Error when month is out of range <URL: http://rt.cpan.org/Ticket/Display.html?id=34736 > On Mon, 7 Apr 2008, Lars Danielsen via RT wrote:
> When dec 32. 2000 is parsed as jan 1. 2001, I suppose that [13th
month]
> 1. 2000 should be jan 1. 2001 as well. Wouldn't you agree?
No, I don't agree. The purpose of the nocheck versions is _not_ to do wacky date math, it is simply to offer a faster version when you _already know_ that your data is valid. The docs say this explicitly: If you are working with data you know to be valid, you can speed your code up by using the "nocheck" variants, "timelocal_nocheck()" and "timegm_nocheck()". -dave /*========================== VegGuide.Org Your guide to all that's veg ==========================*/
Subject: Re: SV: [rt.cpan.org #34736] Error when month is out of range
Date: Tue, 8 Apr 2008 08:35:04 -0500 (CDT)
To: Lars Danielsen via RT <bug-Time-Local [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Tue, 8 Apr 2008, Lars Danielsen via RT wrote: Show quoted text
> I use the feature of april 31. returning may 1. when I generate a > calendar, in that way I don't need to worry about leap year. But since > there is always 12 months in a year, I can do without this feature for > months.
This is _not_ a feature, it simply happens to work, sometimes, with some sets of numbers. Show quoted text
> Another use is to generate a date of "60 days ago" or "4 months from > now". In other languages I have used this behaviour of the date object, > but I guess that I have to find other ways when doing it in perl.
If you want to date math, there are lots of modules for doing this on CPAN. I'd recommend DateTime. -dave /*========================== VegGuide.Org Your guide to all that's veg ==========================*/