in reply to Within A Date Time Range

Thanks voyager and andreychek,

But it breaks :(

This is where I started off before devolving into that nasty nested "if" business. Running that with a start date of today and a start time that's past and a ending date of today and a time that's yet to come results in a "It's before my time!".

i.e.

It's now july 7 2001 and time is 7:43. With lower end of range set for midnight today and the upper end of range is set for noon today.

Variable results are:

$min_time = 997160400

$max_time = 997200000

$now = 994506189

Or am I missing something?

Replies are listed 'Best First'.
Re: Re: Within A Date Time Range
by voyager (Friar) on Jul 07, 2001 at 17:33 UTC
    Check the documentation for Time::Local, in particular what the ranges are for year and month. From the doc:
    It is worth drawing particular attention to the expected ranges for the values provided. While the day of the month is expected to be in the range 1..31, the month should be in the range 0..11. This is consistent with the values returned from localtime() and gmtime().
    Note range for month is 0..11, though days are 1..31! Also, the allowed ranges for year are flexible, though not necessarily what you'd expect.

      geez...

      So all that was required was to subtract 1 from $month1 and $month2 and all is ok?! I read the module and didn't get it. I read the section in the cookbook and still didn't get it. I was even told the month range was 0..11 and I still didn't get a clue.

      I don't want to tell you how many hours I spent on this.

      Thank you very much.

      For pennance this newbie is going to whack himself over the head with all the surrounding Perl books

      BTW, this will be called from another program that pings servers and gateways every five minutes. Should a machine not respond it will check with this script to make sure that the downtime isn't scheduled before sending pages/emails etc.