summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Laban <david.laban@red-badger.com>2020-03-26 17:27:27 +0000
committerJoey Hess <joeyh@joeyh.name>2020-03-26 15:38:34 -0400
commit1ba72338fb5306ca33ae3df4cd9fa663f663002a (patch)
tree237b51fdcb679dbc7e3eaf51a6f97d21a45ea238
parentcf93355af3d86ee665ce103d7d4910f2096b666a (diff)
downloadmoreutils-1ba72338fb5306ca33ae3df4cd9fa663f663002a.tar.gz
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.
-rwxr-xr-xts2
1 files changed, 1 insertions, 1 deletions
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