X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=date.c;h=896fbb48060c673b8dc2f2aa6ea3de3c1042fbd2;hb=dcf9c2e57ab8c916701dd1d4791ef479a3aaf1fc;hp=00f9eb5d0b9730107a8e08e92eb04d4cc9233595;hpb=657072f3ac5519f146a947253c9959909b38c293;p=git.git diff --git a/date.c b/date.c index 00f9eb5d0..896fbb480 100644 --- a/date.c +++ b/date.c @@ -129,8 +129,9 @@ const char *show_date_relative(unsigned long time, int tz, } /* Give years and months for 5 years or so */ if (diff < 1825) { - unsigned long years = diff / 365; - unsigned long months = (diff % 365 + 15) / 30; + unsigned long totalmonths = (diff * 12 * 2 + 365) / (365 * 2); + unsigned long years = totalmonths / 12; + unsigned long months = totalmonths % 12; int n; n = snprintf(timebuf, timebuf_size, "%lu year%s", years, (years > 1 ? "s" : ""));