From c18babad60373c4aada08074a0de62c0e44a80d9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 5 May 2013 11:23:12 -0400 Subject: ts: Fix timezone used with -i Before, -i %.s would print an offset from GMT in seconds, which is wrong. Setting the timezone to GMT internally fixes this, and means it doesn't need to special case use of gmtime to make the default time format work with -i. --- debian/changelog | 6 ++++++ ts | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 833fadd..ccf3c16 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +moreutils (0.49) UNRELEASED; urgency=low + + * ts: Fix timezone used with -i + + -- Joey Hess Sun, 05 May 2013 11:20:57 -0400 + moreutils (0.48) unstable; urgency=low * Allow overriding PREFIX and CFLAGS to make the build more flexible diff --git a/ts b/ts index feda6fd..2a04392 100755 --- a/ts +++ b/ts @@ -68,6 +68,7 @@ my $use_format=@ARGV; my $format="%b %d %H:%M:%S"; if ($inc) { $format="%H:%M:%S"; + $ENV{TZ}='GMT'; } $format=shift if @ARGV; @@ -107,18 +108,14 @@ while (<>) { } my $s=sprintf("%06i", $microseconds); $f=~s/\%\.([Ss])/%$1.$s/g; - if (!$inc) { - print strftime($f, localtime($seconds)); - } else { - print strftime($f, gmtime($seconds)); - } + print strftime($f, localtime($seconds)); } else { if ($inc) { my $seconds = time; my $deltaseconds = $seconds - $lastseconds; $lastseconds = $seconds; - print strftime($format, gmtime($deltaseconds)); + print strftime($format, localtime($deltaseconds)); } else { print strftime($format, localtime); } -- cgit v1.2.3