Sorry Paul, sent this to you instead of the list instead.  ignore the dupe.

On 06/14/2012 12:18 PM, Paul LeoNerd Evans wrote:

> On Thu, Jun 14, 2012 at 05:13:04PM +0100, Paul LeoNerd Evans wrote:
>> Time::Local complains about out-of-range values. It cannot do 25th hour
>> or -3rd day or whatever. Time::mkgmtime specifically allows these, the
>> same way POSIX::mktime() does.
Try using the unchecked versions of the functions from Time::Local
$ perl -MTime::Local=timegm_nocheck -E 'say scalar gmtime timegm_nocheck
0,0,-3,12,6-1,2012-1900'
Mon Jun 11 21:00:00 2012


> To wit, the -3rd hour of the 12th June 2012:
>
> $ perl -MTime::mkgmtime=mkgmtime -E 'say scalar gmtime mkgmtime 
> 0,0,-3,12,6-1,2012-1900'
> Mon Jun 11 21:00:00 2012
>
> $ perl -MTime::Local=timegm -E 'say scalar gmtime timegm 
> 0,0,-3,12,6-1,2012-1900'
> Hour '-3' out of range 0..23 at -e line 1
>
> This behaviour is very much required. It allows one to perform all kinds
> of simple date/time arithmetic; e.g:
>
> sub midnight_four_days_ago {
>   my @t = gmtime;
>   $t[3] -= 4; $t[0]=$t[1]=$t[2] = 0;
>   return mkgmtime @t;
> }
>


Reply via email to