Re: How to see if a time is within two other times.
- From: Arne Ruhnau <krevlar.newsgroups@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 07:32:01 +0200
Ninja67 wrote:
> Mark wrote:
>
>>Ninja67 wrote:
>>
>>>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.
<snip>
> Actually, I discovered that my problem was *far easier* than I first
> thought. The following worked for me:
> my $start = 0;
> my $end = 4;
> if ($hour >= $start && $hour < $end) {
> print "go $hour:$min<br />\n";
> } else {
> print "stop $hour:$min<br />\n";
> }
>
> With just a few more lines, I could work in minutes and seconds if I
> needed. I guess this is an example of "the best solution is the
> simplest."
If it is relevant to you, remember daylight saving times. In Germany, e.g.,
there are days which have the period 2:00am - 2:59am twice, but the latter
is surely after the former. On this day, a range 2:00am - 3:00am is
ambigous unless you go with the convention to name the first 2a o'Clock and
the second 2b o'Clock. (That is one of the reasons why not every day has
86400 seconds *sigh*)
hth,
Arne Ruhnau
.
- References:
- How to see if a time is within two other times.
- From: Ninja67
- Re: How to see if a time is within two other times.
- From: Mark
- Re: How to see if a time is within two other times.
- From: Ninja67
- How to see if a time is within two other times.
- Prev by Date: Re: Tried to install activeperl on windows xp home
- Next by Date: Looking for combination.pm
- Previous by thread: Re: How to see if a time is within two other times.
- Next by thread: Re: How to see if a time is within two other times.
- Index(es):