On Mon, 18 Feb 2002 09:16:47 -0500, someone going by the name of
Chris Nandor <[EMAIL PROTECTED]> communicated:
> #!perl -wl
> use Mac::Files;
> my $info = FSpGetCatInfo('Bourque:Desktop Folder:mp:cpan sites');
> print scalar localtime $info->ioFlCrDat;
> print scalar localtime $info->ioFlMdDat;
Thanks.
In case anyone is interested, I put together these utility routines
for these commands, which returns the date in YYYY/MM/DD format.
(These, of course, assume that "use Mac::Files" is declared
beforehand.)
sub get_creation_date {
# return the creation date of the specified file (in YYYY/MM/DD format)
my ($file) = @_;
if ( -f $file ) {
my $info = FSpGetCatInfo($file);
my ($mday,$mon,$year) = (localtime($info->ioFlCrDat))[3..5];
$year+=1900; $mon=padnum($mon+1); $mday=padnum($mday);
return "$year/$mon/$mday";
} else {
return "";
}
} # sub get_creation_date
sub get_modification_date {
# return the modification date of the specified file (in YYYY/MM/DD format)
my ($file) = @_;
if ( -f $file ) {
my $info = FSpGetCatInfo($file);
my ($mday,$mon,$year) = (localtime($info->ioFlMdDat))[3..5];
$year+=1900; $mon=padnum($mon+1); $mday=padnum($mday);
return "$year/$mon/$mday";
} else {
return "";
}
} # sub get_modification_date
"padnum" is a routine I created to put in initial zeroes. (Yes, I'm
sure that there is a more efficient way to do it.)
sub padnum {
# pad number with initial zeroes if less than specified digits (default 2)
my ($num,$digits) = @_;
$num += 0;
if ( $digits == 0 ) { $digits = 2; }
while ( length($num) < $digits ) { $num = "0$num"; }
return ( $num );
} # padnum
--
Tim Bailey |\/ "I sat alone in the dark one night, tuning in
[EMAIL PROTECTED] |\/ by remote / I found a preacher who spoke of
[EMAIL PROTECTED] | the light, but there was brimstone in his
http://www.moonrise.org throat / He'd show me the way according to him
--'--,--<@ @>--`--,-- in return for my personal check / I flipped my
------(36,111 days to)----- channel back to CNN and lit another
-----(the new Century!)---- cigarette."
-- Mary-Chapin Carpenter, "I Take My Chances"