From 1ba72338fb5306ca33ae3df4cd9fa663f663002a Mon Sep 17 00:00:00 2001 From: David Laban Date: Thu, 26 Mar 2020 17:27:27 +0000 Subject: fix iso date parsing With this patch applied, you should be able to do: kubectl logs --timestamps | ts -r and receive relative timestamps in your output. --- Review by Joey: This fixes the year to have 4 digits, which seems obviously right. It also allows a trailing Z, for dates in UTC. Other dates already matched by this regexp can have time zones, and ts just ignores time zones and assumes it's in the local time zone. I don't know if that's really a good idea, but accepting "Z" does not open a new can of worms. --- ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts b/ts index 28c4e38..af23cf7 100755 --- a/ts +++ b/ts @@ -170,7 +170,7 @@ while (<>) { | \w{3}\s+\d{1,2}\s+\d\d:\d\d:\d\d # syslog form | - \d\d\d[-:]\d\d[-:]\d\dT\d\d:\d\d:\d\d.\d+ # ISO-8601 + \d\d\d\d[-:]\d\d[-:]\d\dT\d\d:\d\d:\d\d.\d+Z? # ISO-8601 | (?:\w\w\w,?\s+)? # (optional Day) \d+\s+\w\w\w\s+\d\d+\s+\d\d:\d\d:\d\d -- cgit v1.2.1