Re: How to see if a time is within two other times.



"Ninja67" <Ninja67@xxxxxxxxx> wrote in
news:1120074745.373483.169390@xxxxxxxxxxxxxxxxxxxxxxxxxxxx:

> I need to modify a script in such a way that it checks the current
> time (according to the server) to determine if the current time falls
> within a particular time span such as midnight to 4:00 am.

Time::Local can help:

#!/usr/bin/perl

use strict;
use warnings;

use Time::Local;

# 2005/06/29 16:00:00
my $start = timelocal(0, 0, 16, 29, 5, 2005);
my $end = $start + (4 * 60 * 60);


if($start <= time and time <= $end) {
run();
} else {
expired();
}

sub run { print "Running\n" }

sub expired { print "Expired\n" }

__END__


Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
.



Relevant Pages