Code

Introduce commit notes
[git.git] / date.c
diff --git a/date.c b/date.c
index 8e57e5eb82450a448ea8096cf4a87810b58226c3..5d05ef61cfb140f004702a5ed614afa755c50670 100644 (file)
--- a/date.c
+++ b/date.c
@@ -123,7 +123,7 @@ const char *show_date_relative(unsigned long time, int tz,
                return timebuf;
        }
        /* Say months for the past 12 months or so */
-       if (diff < 360) {
+       if (diff < 365) {
                snprintf(timebuf, timebuf_size, "%lu months ago", (diff + 15) / 30);
                return timebuf;
        }
@@ -857,7 +857,9 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
        }
 
        if (match_string(date, "months") >= 5) {
-               int n = tm->tm_mon - *num;
+               int n;
+               update_tm(tm, now, 0); /* fill in date fields if needed */
+               n = tm->tm_mon - *num;
                *num = 0;
                while (n < 0) {
                        n += 12;
@@ -868,6 +870,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
        }
 
        if (match_string(date, "years") >= 4) {
+               update_tm(tm, now, 0); /* fill in date fields if needed */
                tm->tm_year -= *num;
                *num = 0;
                return end;