summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-05-05 11:23:12 -0400
committerJoey Hess <joey@kitenet.net>2013-05-05 11:23:12 -0400
commitc18babad60373c4aada08074a0de62c0e44a80d9 (patch)
treeb2a05e3176aef0f1fb7f38617c5a0337565d4b18
parent337a7415b11bb2b3a5f47a1aa96b571a40da8762 (diff)
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.
-rw-r--r--debian/changelog6
-rwxr-xr-xts9
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 <joeyh@debian.org> 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);
}