On Fri, Aug 28, 2009 at 09:03:19PM +0200, Alex Riesen wrote: > +unsigned long approxidate(const char *date) > +{ > + struct timeval tv; > + gettimeofday(&tv, NULL); > + return approxidate_relative(date, &tv); > +} This now always calls gettimeofday, whereas the original approxidate only did if parse_date failed. I think you could also make this patch much smaller by just wrapping the whole function and using a '0' sentinel for "you need to fill in the time." Like: --- diff --git a/date.c b/date.c index 409a17d..b084d19 100644 --- a/date.c +++ b/date.c @@ -86,6 +86,14 @@ static int local_tzoffset(unsigned long time) const char *show_date(unsigned long time, int tz, enum date_mode mode) { + struct timeval now; + now.tv_sec = 0; + show_date_at_time(time, tz, mode, &now); +} + +const char *show_date_at_time(unsigned long time, int tz, enum date_mode mode, + struct timeval now) +{ struct tm *tm; static char timebuf[200]; @@ -96,8 +104,8 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode) if (mode == DATE_RELATIVE) { unsigned long diff; - struct timeval now; - gettimeofday(&now, NULL); + if (!now.tv_sec) + gettimeofday(&now, NULL); if (now.tv_sec < time) return "in the future"; diff = now.tv_sec - time; On the other hand, refactoring the relative date code into its own function is probably a good thing in the long run. -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html