[CLUE-Tech] databases and timestamps ... 'since' idiom
Jeffery C. Cann
jccann at home.com
Sun Mar 18 08:52:17 MST 2001
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Saturday 17 March 2001 22:34, Dave Price wrote:
> Is the time_t time format the same as a *nix time stamps?
Yes. time_t is the C language structure to hold a time stamp.
> Is there a core module that handles time_t, or do i need a CPAN module
> added? One weird bit, I sometimes like to 'predigest' my text files a bit
> under active state for win32.
PERL supports the time_t time stamp natively. If you are looking at files, I
often use the last modified time. I use the 'stat()' or 'lstat()' built-in
PERL function.
Here is a simple example. Both $ftime and $now will contain large integers
that represent the number of seconds since the epoch. So, you can reliably
compare their timestamps.
I take the ninth element from the array returned by stat because (check
perldoc page on stat) it is the mtime of the file (i.e., the last
modification time),
my $ftime = stat( '/home/jccann/bob.txt' ) [ 9 ];
my $now = time();
if ( $ftime < $now ) {
print 'my file is older than now';
}
You also can also take a formatted string and build a timestamp. I haven't
done this in PERL. Probably you want to check the PERL cookbook or CPAN for
an example.
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjq02bUACgkQw3/GBQk72kA3CgCbBmFXdASfdPWHfFvf3xQCHDyz
KmEAniX9JXIBSdlIKUNA26RNKagpuqIf
=wL3Q
-----END PGP SIGNATURE-----
More information about the clue-tech
mailing list