Download raw body.
On Mon, Nov 02, 2026 at 02:38:43PM +0100, Christian Schulte wrote:
> Do not use 'Z'. Use '%z'.
Sure... but let's save some space in case it is +0000. Maybe like so?
This changes the ts(1) default format to ISO8601.
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 14:48:34 -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-02T14:24:50Z foo
+2026-11-02T14:24:52Z 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 14:48:34 -0000
@@ -34,7 +34,7 @@ struct usec {
char *pos;
};
-static char *format = "%b %d %H:%M:%S";
+static char *format;
static char *buf;
static char *outbuf;
static size_t bufsize;
@@ -44,6 +44,17 @@ static void fmtfmt(void);
static void fmtprint(const struct timespec *);
static void __dead usage(void);
+static int
+localtz_is_utc(void)
+{
+ time_t now;
+ struct tm *local;
+
+ now = time(NULL);
+ local = localtime(&now);
+ return local->tm_gmtoff == 0;
+}
+
int
main(int argc, char *argv[])
{
@@ -87,6 +98,12 @@ main(int argc, char *argv[])
if (argc == 1)
format = *argv;
+ else {
+ if (localtz_is_utc())
+ format = "%Y-%m-%dT%H:%M:%SZ";
+ else
+ format = "%Y-%m-%dT%H:%M:%S%z";
+ }
bufsize = strlen(format) + 1;
if (bufsize > SIZE_MAX / 10)