diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-11-27 17:18:56 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-11-27 17:18:56 -0400 |
commit | 19d1bde3491f737c2d3babd94de0de8eb9d9b1c9 (patch) | |
tree | 3dbf686565f59de34d48c28abaef904b5a9f382d | |
parent | 3d31d550ffc75f7eada0d6cb624a98423b54bbd2 (diff) | |
download | moreutils-19d1bde3491f737c2d3babd94de0de8eb9d9b1c9.tar.gz |
ts: Added %.T format like %T but with hi-res.
Thanks, Matt Koscica
-rw-r--r-- | debian/changelog | 2 | ||||
-rwxr-xr-x | ts | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog index bf80599..1c08f38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ moreutils (0.62) UNRELEASED; urgency=medium * ts: Add -m option to use monotonic clock. Thanks, Ben Leinweber + * ts: Added %.T format like %T but with hi-res. + Thanks, Matt Koscica -- Joey Hess <id@joeyh.name> Mon, 30 Oct 2017 12:49:18 -0400 @@ -14,9 +14,10 @@ ts adds a timestamp to the beginning of each line of input. 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" and "%.s" -are like "%S" and "%s", but provide subsecond resolution -(ie, "30.00001" and "1301682593.00001"). +addition to the regular strftime conversion specifications, +"%.S" and "%.s" and "%.T" +are like "%S" and "%s" and "%T", but provide subsecond resolution +(ie, "30.00001" and "1301682593.00001" and "1:15:30.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 @@ -85,7 +86,7 @@ $format=shift if @ARGV; # For subsecond resolution, Time::HiRes is needed. my $hires=0; -if ($format=~/\%\.[Ss]/ || $mono) { +if ($format=~/\%\.[SsT]/ || $mono) { require Time::HiRes; use Time::HiRes qw(CLOCK_MONOTONIC); $hires=1; @@ -140,7 +141,7 @@ while (<>) { $microseconds = $deltamicroseconds; } my $s=sprintf("%06i", $microseconds); - $f=~s/\%\.([Ss])/%$1.$s/g; + $f=~s/\%\.([SsT])/%$1.$s/g; print strftime($f, localtime($seconds)); } else { |