Hi Behzad,

(snipped)


 
CASE 1
----------
> use Time::Local 'timelocal_nocheck';


use Time::Local qw(timelocal_nocheck timelocal);


Should fix that :-)
 

 
CASE 2
----------
> Use Time::Local;
 
> Use of uninitialized value in integer multiplication (*) at
>        C:/Perl/lib/Time/Local.pm line 76 (#1)
 
>        Day '31' out of range 1..30 at c:\................myCode.pl 98
>        At C:/Perl/lib/Time/Local.pm line 116
>        Time::Local::timegm called at C:/Perl/lib/Time/Local/pm line
153
>        Time::Local::timelocal(0, 0, 0, 31, 08, 2004) called at
>C:\....myCode.pl line 98

>From the Time::Local Docs 

 It is worth drawing particular attention to the expected ranges for the
values provided. The value for the day of the month is the actual day
(ie 1..31), while the month is the number of months since January
(0..11). This is consistent with the values returned from localtime()
and gmtime().

So, If you wanted a date of Aug 31, 2004 the call to timelocal
Should be:
my $time = timelocal(0, 0, 0, 31, 7, 2004);

And to confirm
use strict;
use DateTime;
use warnings;
use Time::Local qw(timelocal_nocheck timelocal);

my $time = timelocal(0, 0, 0, 31, 7, 2004);

my $dt = DateTime->from_epoch( epoch => $time );

print $dt->mdy;

prints:
D:\scripts>me.pl
08-31-2004

I hope this helps

Ron Hill

Reply via email to