prborg has asked for the wisdom of the Perl Monks concerning the following question:
Everything is working just fine. It grabs the date and everything, but my concern is how to handle Daylight Savings Time? When DST goes back 1 hr I'll end up processing the same files twice and when it moves forward 1 hr I'll end up skipping an hour of files. Any ideas will be appreciated. Thanks for your wisdom.#!/usr/bin/perl $hr = (localtime(time))[2]; if ($hr == 0) { $hr = 23; @tdate = localtime(time - 86400); } else { $hr -= 1; @tdate = localtime(time); } $day = $tdate[3]; $mon = $tdate[4] + 1; $yr = $tdate[5] + 1900; $fname = sprintf("files.%4d%02d%02d%02d*.gz", $yr, $mon, $day, $hr); `cp /foo/$fname /bar/`;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: date issues
by kennethk (Abbot) on Feb 20, 2009 at 17:50 UTC | |
by prborg (Initiate) on Feb 20, 2009 at 18:40 UTC | |
|
Re: date issues
by ikegami (Patriarch) on Feb 20, 2009 at 18:33 UTC |