GhodMode, there is a subtle race-condition in your example. Since you are calling localtime twice, it could potentially return two different values. For instance, say you ran the code right as the clock struck ten:
Now your code would act as if it's 9:00pm, when in fact it's 10:00pm. Not trying to nit-pick, but I just couldn't help noticing... ;-)my $current_hour = strftime( "%H", localtime() ); # say it's 9:59, so +"9" is returned. # ... your process is switched off the processor... my $current_minute = strftime( "%M", localtime() ); # now it's 10:00, +so "00" is returned.
If it were me, I would keep the "closing time" in 24-hour format (I realize the OP doesn't in his/her example) and completely forgo the use of strftime:
#my $store_close = "7:05 PM"; my $store_close = "19:05"; my ($close_hour, $close_minute) = split( /:/, $store_close ); my ($current_minute, $current_hour) = (localtime)[1,2];
In reply to Re^2: Comparing a string value's time with the computers time
by crashtest
in thread Comparing a string value's time with the computers time
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |