+moreutils (0.45) UNRELEASED; urgency=low
+
+ * ts: Support %.s for seconds sinch epoch with subsecond resolution.
+ Closes: #619764
+
+ -- Joey Hess <joeyh@debian.org> Fri, 01 Apr 2011 14:34:15 -0400
+
moreutils (0.44) unstable; urgency=low
* pee: Propigate exit status of commands run.
The optional format parameter controls how the timestamp is formatted,
as used by L<strftime(3)>. The default format is "%b %d %H:%M:%S". In
-addition to the regular strftime conversion specifications, "%.S" is
-expanded to fractional seconds (ie, "30.00001").
+addition to the regular strftime conversion specifications, "%.S" and "%.s"
+are like "%S" and "%s", but provide subsecond resolution
+(ie, "30.00001" and "1301682593.00001").
If the -r switch is passed, it instead converts existing timestamps in
the input to relative times, such as "15m5s ago". Many common timestamp
my $format="%b %d %H:%M:%S";
$format=shift if @ARGV;
-# For fractional seconds, Time::HiRes is needed.
+# For subsecond resolution, Time::HiRes is needed.
my $hires=0;
-if ($format=~/\%\.S/) {
+if ($format=~/\%\.[Ss]/) {
require Time::HiRes;
$hires=1;
}
my $f=$format;
my ($seconds, $microseconds) = Time::HiRes::gettimeofday();
my $s=sprintf("%06i", $microseconds);
- $f=~s/\%\.S/%S.$s/g;
+ $f=~s/\%\.([Ss])/%$1.$s/g;
print strftime($f, localtime($seconds));
}
else {