------------------------------------------------
On Thu, 30 Jan 2003 09:34:12 -0500 (EST), John Baker <[EMAIL PROTECTED]> wrote:
> #-- This module is a must-have:
> use Date::Manip;
>
> # Get properly formatted modify time of file from epoch
> my $fmodtime = (stat($fh))[9];
> my $mod_parse = &ParseDateString("epoch $fmodtime");
>
> # Check for GMT, if not, convert
> my ($dnow, $secs, $now_parse, $delta_string);
> if ($tz !~ /^GMT$/) { $dnow = Date_ConvTZ($now,"","GMT"); }
> else { $dnow = $now; }
>
> # Get properly formatted current time from epoch
> my ($m,$d,$y,$h,$mn,$s) = (split(/,/ ,$dnow));
> $secs = &Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);
> $now_parse = &ParseDateString("epoch $secs");
>
> $delta_string = DateCalc($mod_parse,$now_parse,\$err);
>
> ---
> This is code I've extracted from an application I wrote and
> maintain. It's comparing the current time with the last
> mod time. I'm interested in this delta in order to determine
> whether to update a file or not (if older than 3 hours update,
> if not, don't).
>
> So the point is, stat() and Date::Manip is one way to solve your
> problem.
>
> jab
>
> perldoc -f stat
> perldoc /path/to/perl5/site_perl/5.6.1/Date/Manip.pod
>
I agree that Date::Manip is a great module for complex date manipulations, but for
what you are doing it is major overkill no? Why not just take 'time()' which is now,
subtract 3 hours worth of seconds... 60*60*3 ... and then compare that integer to the
stat[9] time that you get? If it is greater you need to reprocess the file...
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]