use gmtime_r(3) instead of localtime_r(3) to display time in UTC as intended Problem noticed by naddy due to failing regress tests at midnight, and then analyzed with additional help from millert. ok naddy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/got/got.c b/got/got.c
index f48598b..b008eec 100644
--- a/got/got.c
+++ b/got/got.c
@@ -4659,8 +4659,8 @@ blame_cb(void *arg, int nlines, int lineno, struct got_object_id *id)
}
committer_time = got_object_commit_get_committer_time(commit);
- if (localtime_r(&committer_time, &tm) == NULL)
- return got_error_from_errno("localtime_r");
+ if (gmtime_r(&committer_time, &tm) == NULL)
+ return got_error_from_errno("gmtime_r");
if (strftime(bline->datebuf, sizeof(bline->datebuf), "%G-%m-%d",
&tm) == 0) {
err = got_error(GOT_ERR_NO_SPACE);
@@ -8414,8 +8414,8 @@ get_commit_brief_str(char **brief_str, struct got_commit_object *commit)
char *logmsg0 = NULL, *logmsg, *newline;
committer_time = got_object_commit_get_committer_time(commit);
- if (localtime_r(&committer_time, &tm) == NULL)
- return got_error_from_errno("localtime_r");
+ if (gmtime_r(&committer_time, &tm) == NULL)
+ return got_error_from_errno("gmtime_r");
if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d", &tm) == 0)
return got_error(GOT_ERR_NO_SPACE);
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 7d851f4..360a75d 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -3909,8 +3909,8 @@ gw_blame_cb(void *arg, int nlines, int lineno, struct got_object_id *id)
}
committer_time = got_object_commit_get_committer_time(commit);
- if (localtime_r(&committer_time, &tm) == NULL)
- return got_error_from_errno("localtime_r");
+ if (gmtime_r(&committer_time, &tm) == NULL)
+ return got_error_from_errno("gmtime_r");
if (strftime(bline->datebuf, sizeof(bline->datebuf), "%G-%m-%d",
&tm) == 0) {
err = got_error(GOT_ERR_NO_SPACE);
diff --git a/tog/tog.c b/tog/tog.c
index c175ea3..fc51be8 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1340,8 +1340,8 @@ draw_commit(struct tog_view *view, struct got_commit_object *commit,
struct tog_color *tc;
committer_time = got_object_commit_get_committer_time(commit);
- if (localtime_r(&committer_time, &tm) == NULL)
- return got_error_from_errno("localtime_r");
+ if (gmtime_r(&committer_time, &tm) == NULL)
+ return got_error_from_errno("gmtime_r");
if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) == 0)
return got_error(GOT_ERR_NO_SPACE);