Alloun, Jonathan wrote:
> Is there a module out there that will compare two dates??
Probably. There's tons of Date modules out there. Maybe Date::Calc or
Date::Manip.
> For example: (date format is dd mm yyyy)
>
> I have one date in a file: 10 12 2000
>
> and another passed into the script which I have formatted as
> 11 12 2000
>
> I need to check that the date in the file is less than the
> one passed into the script??
You could convert each date to seconds since the epoch with
Time::Local::timelocal. Probably better than loading a big ol' multi-purpose
date module.
#!perl -w
use strict;
use Time::Local;
sub makesecs ($) {
my($d, $m, $y) = shift =~ /^(\d+)\s+(\d+)\s+(\d+)$/;
$y -= 1900;
$m -= 1;
return timelocal 0, 0, 12, $d, $m, $y;
}
my $filedate = '10 12 2000';
my $scriptdate = '11 12 2000';
my $filesecs = makesecs($filedate);
my $scriptsecs = makesecs($scriptdate);
if($filesecs < $scriptsecs) {
print "File date is earlier.\n";
} else {
print "File date is later.\n";
}
Cheers,
Philip
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users