On Thu, 30 Jan 2003 [EMAIL PROTECTED] wrote:

> Date: Thu, 30 Jan 2003 07:59:11 -0500
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: TimeStamp compare
>
> Hi there mates,
>
>    I would like to Know If anyone of you have already tried to get the time and
> date a file was created from the OS. For example imagine I have a *.java file
> and I would like to compare the *.class file date of creation with the date of
> edition of the *.java file in other to make sure the *.class file was generated
> (compiled ) or not after the *.java new edition.
>
> I hope I�ve made myself clear ,
> Thks in advance.
>
#-- 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


--------
Be straight and to the point. Don't waste others' time.
Do your homework before you ask for help.

--Unknown


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to