mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
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:
parent
0bbaf4a296
commit
34e95bb4a5
1 changed files with 2 additions and 4 deletions
|
|
@ -62,15 +62,13 @@ char *current_time(void)
|
||||||
case TIMESTAMP_24HOUR_START:
|
case TIMESTAMP_24HOUR_START:
|
||||||
// "hh:mm:ss.sss" (24 hour format relative to start time)
|
// "hh:mm:ss.sss" (24 hour format relative to start time)
|
||||||
timersub(&tv_now, &tv_start, &tv);
|
timersub(&tv_now, &tv_start, &tv);
|
||||||
tv.tv_sec -= 3600; // Why is this needed??
|
tm = gmtime(&tv.tv_sec);
|
||||||
tm = localtime(&tv.tv_sec);
|
|
||||||
len = strftime(time_string, sizeof(time_string), "%H:%M:%S", tm);
|
len = strftime(time_string, sizeof(time_string), "%H:%M:%S", tm);
|
||||||
break;
|
break;
|
||||||
case TIMESTAMP_24HOUR_DELTA:
|
case TIMESTAMP_24HOUR_DELTA:
|
||||||
// "hh:mm:ss.sss" (24 hour format relative to previous time stamp)
|
// "hh:mm:ss.sss" (24 hour format relative to previous time stamp)
|
||||||
timersub(&tv_now, &tv_previous, &tv);
|
timersub(&tv_now, &tv_previous, &tv);
|
||||||
tv.tv_sec -= 3600; // Why is this needed??
|
tm = gmtime(&tv.tv_sec);
|
||||||
tm = localtime(&tv.tv_sec);
|
|
||||||
len = strftime(time_string, sizeof(time_string), "%H:%M:%S", tm);
|
len = strftime(time_string, sizeof(time_string), "%H:%M:%S", tm);
|
||||||
break;
|
break;
|
||||||
case TIMESTAMP_ISO8601:
|
case TIMESTAMP_ISO8601:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue