Like this:


    use Time::Local;

    @time = (31, 1, 101);

    @newtime = (localtime(timelocal (0, 0, 0, @time)))[3..5];

    $good = ("@time" eq "@newtime");


Cheers,

Rob


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Rodney
> Wines
> Sent: 16 August 2001 14:59
> To: David Mintz; [EMAIL PROTECTED]
> Subject: Re: easiest way to check a date for validity
> 
> 
> > use Time::Local;
> > $time = timelocal(0,0,0,31,1,101); # February 31, 2001 (!)
> > print scalar localtime($time);     # says March 3, 2001
> 
> You've got a solution right there.  Convert to timelocal, then localtime,
> and compare the results.  If they're the same, the time is good.  I'm not
> saying there aren't better ways, but it'll work ...
> 
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activeperl
> 
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to