Mailing List Archive

Proposed Perl Change; Time::HiRes module - add localtime and strftime
Hi,

Time::HiRes::stat() and siblings exist and work, but nothing exists to use
their output (e.g. both localtime and strftime truncate the decimals)., so
I propose adding Time::HiRes::localtime() and Time::HiRes::strftime() which
are identical to localtime() and strftime(), except returning the "seconds"
portion of times as floats (%S, %r, %X). It's an addition, so shouldn't
pose any problems.

example of current irritating behaviour:-

perl -MPOSIX -MTime::HiRes -e '
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
$ctime, $blksize, $blocks)=Time::HiRes::lstat("myfile.html");
print $mtime . "\n" .
join(",",localtime($mtime)) . "\n" .
strftime("%Y-%m-%d %H:%M:%S", 4.89247,57,3,11,10,123,6,314,0) . strftime("
%z", localtime()) . "\n";'

gives:-

1699675024.89247
4,57,3,11,10,123,6,314,0
2023-11-11 03:57:04 +0000

but we *wanted* this (imaginary output from new Time::HiRes::localtime()
and Time::HiRes::strftime() ):-
1699675024.89247
4.89247,57,3,11,10,123,6,314,0
2023-11-11 03:57:04.89247 +0000


Kind regards,
Chris Drake.