X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=date.c;h=f011692c2f9f06e2356c2256ff8f1b496a1af2d5;hb=cfe370c6476392095bc3f18013d195b1cccd6184;hp=1165d30adfa783f7cbaa871e38a1370f9f9c4996;hpb=2254da06a5473ffde973337bad2c6a96eea61e20;p=git.git diff --git a/date.c b/date.c index 1165d30ad..f011692c2 100644 --- a/date.c +++ b/date.c @@ -135,7 +135,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode) } /* Give years and months for 5 years or so */ if (diff < 1825) { - unsigned long years = (diff + 183) / 365; + unsigned long years = diff / 365; unsigned long months = (diff % 365 + 15) / 30; int n; n = snprintf(timebuf, sizeof(timebuf), "%lu year%s", @@ -871,13 +871,15 @@ unsigned long approxidate(const char *date) int number = 0; struct tm tm, now; struct timeval tv; + time_t time_sec; char buffer[50]; if (parse_date(date, buffer, sizeof(buffer)) > 0) return strtoul(buffer, NULL, 10); gettimeofday(&tv, NULL); - localtime_r(&tv.tv_sec, &tm); + time_sec = tv.tv_sec; + localtime_r(&time_sec, &tm); now = tm; for (;;) { unsigned char c = *date;