Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Time::Local has a function called timelocal (surprise) that converts information like that returned from localtime back into epoch seconds (like that returned from time). Consider this:
That should sleep until 8am the following day, but if you start that after midnight and before 8am, it won't work quite right. A little logic can fix that (add 1 to $mday unless the current hour is less than 8). Also it gets even more complicated if it's the last day of the month. That will break this completely and requires a lot more work to check for. And what if it's the last day of the year too? You'll need to check for that. Ok, so you set all that up too, but it's Februrary 28th on a leap year. Oops broke again. In other words, it ain't easy. Maybe you should use Date::Calc. Update I thought of something that might work also that doesn't involve these kinds of calculations. Sleep for 1 second until it's 8am, perhaps like so:
Just an idea.
In reply to Re: How long 'tween now and then?
by reptile
|
|