From 34e95bb4a54dd4f7323fdf31bdd559341dee4b3e Mon Sep 17 00:00:00 2001 From: Ralph Siemsen Date: Mon, 18 Jul 2022 18:56:08 +0200 Subject: [PATCH] Fix relative timestamps Fix the display of relative timestamps. The hack of subtracting 3600 only works if you happen to be in a time zone that is one hour away from UTC. When subtracting two time values, the result is an absolute quantity (interval). These should be displayed as-is; without local time zone nor daylight saving correction. Hence gmtime() instead of localtime(). --- src/misc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/misc.c b/src/misc.c index 8ab8970..f51c69c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -62,15 +62,13 @@ char *current_time(void) case TIMESTAMP_24HOUR_START: // "hh:mm:ss.sss" (24 hour format relative to start time) timersub(&tv_now, &tv_start, &tv); - tv.tv_sec -= 3600; // Why is this needed?? - tm = localtime(&tv.tv_sec); + tm = gmtime(&tv.tv_sec); len = strftime(time_string, sizeof(time_string), "%H:%M:%S", tm); break; case TIMESTAMP_24HOUR_DELTA: // "hh:mm:ss.sss" (24 hour format relative to previous time stamp) timersub(&tv_now, &tv_previous, &tv); - tv.tv_sec -= 3600; // Why is this needed?? - tm = localtime(&tv.tv_sec); + tm = gmtime(&tv.tv_sec); len = strftime(time_string, sizeof(time_string), "%H:%M:%S", tm); break; case TIMESTAMP_ISO8601: