From fae19c94920cff2a7132ed6721f813b923ddbf60 Mon Sep 17 00:00:00 2001 From: Tvrtko Ursulin Date: Mon, 9 Jul 2018 13:46:10 +0100 Subject: trace.pl: Fix HTML timestamp generation Now that we scale timestamps to get better timeline granularity, the hacky hand rolled micro-second time to HTML date conversion does no longer cut it. Use perl built-in gmtime to handle things properly. v2: Do not bother with the epoch since timeline times are relative to unknown system boot time. (John Harrison) Signed-off-by: Tvrtko Ursulin Cc: John Harrison Reviewed-by: John Harrison --- scripts/trace.pl | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/trace.pl b/scripts/trace.pl index fd414f5a..fa38e041 100755 --- a/scripts/trace.pl +++ b/scripts/trace.pl @@ -332,22 +332,15 @@ sub sanitize_ctx sub ts { my ($us) = @_; - my ($d, $h, $m, $s); + my ($y, $mo, $d, $h, $m, $s); $s = int($us / 1000000); $us = $us % 1000000; - $m = int($s / 60); - $s = $s % 60; + ($s, $m, $h, $d, $mo, $y) = gmtime($s); - $h = int($m / 60); - $m = $m % 60; - - $d = 1 + int($h / 24); - $h = $h % 24; - - return sprintf('2017-01-%02u %02u:%02u:%02u.%06u', - int($d), int($h), int($m), int($s), int($us)); + return sprintf('%04u-%02u-%02u %02u:%02u:%02u.%06u', + $y, 1 + $mo, $d, $h, $m, $s, int($us)); } # Main input loop - parse lines and build the internal representation of the -- cgit v1.2.3