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().
This commit is contained in:
Ralph Siemsen 2022-07-18 18:56:08 +02:00 committed by Martin Lund
parent 0bbaf4a296
commit 34e95bb4a5

View file

@ -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: