date.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/date.c b/date.c index 9809ac334..de0b03cf4 100644 --- a/date.c +++ b/date.c @@ -199,7 +199,7 @@ struct date_mode *date_mode_from_type(enum date_mode_type type) return &mode; } -static void show_date_normal(struct strbuf *buf, struct tm *tm, int tz, struct tm *human_tm, int human_tz, int local) +static void show_date_normal(struct strbuf *buf, timestamp_t time, struct tm *tm, int tz, struct tm *human_tm, int human_tz, int local) { struct { unsigned int year:1, @@ -225,6 +225,14 @@ static void show_date_normal(struct strbuf *buf, struct tm *tm, int tz, struct t } } + /* Show "today" times as just relative times */ + if (hide.wday) { + struct timeval now; + gettimeofday(&now, NULL); + show_date_relative(time, tz, &now, buf); + return; + } + /* Always hide seconds for human-readable */ hide.seconds = human_tm->tm_year > 0; @@ -268,10 +276,6 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode) /* Fill in the data for "current time" in human_tz and human_tm */ human_tz = local_time_tzoffset(now.tv_sec, &human_tm); - /* Special case: if it's less than an hour ago, use relative time */ - if (time - now.tv_sec < 60 * 60) - type = DATE_RELATIVE; - /* Don't print timezone if it matches */ if (tz == human_tz) local = 1; @@ -333,7 +337,7 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode) strbuf_addftime(&timebuf, mode->strftime_fmt, tm, tz, !local); else - show_date_normal(&timebuf, tm, tz, &human_tm, human_tz, local); + show_date_normal(&timebuf, time, tm, tz, &human_tm, human_tz, local); return timebuf.buf; }