Download raw body.
ts(1) - ISO8601 as default format
ts(1) & ISO8601 by default (Was: httpd: add timestamps to fastcgi error log)
On Mon, Nov 02, 2026 at 03:01:00PM +0000, Stuart Henderson wrote:
> > +static int
> > +localtz_is_utc(void)
> > +{
> > + time_t now;
> > + struct tm *local;
> > +
> > + now = time(NULL);
> > + local = localtime(&now);
> > + return local->tm_gmtoff == 0;
> > +}
>
> that messes up the formatting if run across a DST change in +0000/+0100
> timezones (Europe/Dublin, Europe/Jersey, Europe/London, etc).
Gaaah... why is it so hard to figure out if the system timezone is Etc/UTC?
Perhaps it is better to just start with using ISO8601, and possibly
later on use 'Z' instead of '+0000' if the systemzone is Etc/UTC.
How about
Index: ts.1
===================================================================
RCS file: /cvs/src/usr.bin/ts/ts.1,v
diff -u -p -r1.8 ts.1
--- ts.1 3 Jul 2022 16:55:39 -0000 1.8
+++ ts.1 2 Nov 2026 15:34:18 -0000
@@ -52,7 +52,7 @@ specifications described in the
.Xr strftime 3
manual page.
The default format is
-.Qq %b %d %H:%M:%S ;
+.Qq %Y-%m-%dT%H:%M:%S%z ;
or
.Qq %H:%M:%S
if one of the
@@ -79,9 +79,9 @@ and
.Qq 4:20:00.00001 .
.Sh EXAMPLES
.Bd -literal -offset indent
-$ (echo foo; sleep 2; echo bar) | ts
-Jun 28 12:13:38 foo
-Jun 28 12:13:40 bar
+$ (echo foo; sleep 2; echo bar) | TZ=Etc/UTC ts
+2026-11-02T15:32:53+0000 foo
+2026-11-02T15:32:55+0000 bar
$ ls | ts -i %.S
00.000452 CVS
Index: ts.c
===================================================================
RCS file: /cvs/src/usr.bin/ts/ts.c,v
diff -u -p -r1.11 ts.c
--- ts.c 11 Oct 2022 07:36:27 -0000 1.11
+++ ts.c 2 Nov 2026 15:34:18 -0000
@@ -34,7 +34,7 @@ struct usec {
char *pos;
};
-static char *format = "%b %d %H:%M:%S";
+static char *format = "%Y-%m-%dT%H:%M:%S%z";
static char *buf;
static char *outbuf;
static size_t bufsize;
ts(1) - ISO8601 as default format
ts(1) & ISO8601 by default (Was: httpd: add timestamps to fastcgi error log)