@matheusbsbs / matheus-bagliano / commits / 73013afd14
Fork 0

Make show_rfc2822_date() just another date output format.

These days, show_date() takes a date_mode parameter to specify the output format, and a separate specialized function for dates in E-mails does not make much sense anymore. This retires show_rfc2822_date() function and make it just another date output format. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jul 13, 2007 at 23:14 UTC 73013afd14c14ba178ab2aaa458168ec1d5506de
5 files changed +21 -24
cache.h
+9 -2
@@ -409,9 +409,16 @@ extern void *read_object_with_reference(const unsigned char *sha1,
409 unsigned long *size,
410 unsigned char *sha1_ret);
411
412 -enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL, DATE_ISO8601 };
412 +enum date_mode {
413 + DATE_NORMAL = 0,
414 + DATE_RELATIVE,
415 + DATE_SHORT,
416 + DATE_LOCAL,
417 + DATE_ISO8601,
418 + DATE_RFC2822
419 +};
420 +
421 const char *show_date(unsigned long time, int timezone, enum date_mode mode);
414 -const char *show_rfc2822_date(unsigned long time, int timezone);
422 int parse_date(const char *date, char *buf, int bufsize);
423 void datestamp(char *buf, int bufsize);
424 unsigned long approxidate(const char *);
commit.c
+4 -4
@@ -585,7 +585,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
585 break;
586 case CMIT_FMT_EMAIL:
587 ret += sprintf(buf + ret, "Date: %s\n",
588 - show_rfc2822_date(time, tz));
588 + show_date(time, tz, DATE_RFC2822));
589 break;
590 case CMIT_FMT_FULLER:
591 ret += sprintf(buf + ret, "%sDate: %s\n", what,
@@ -778,9 +778,9 @@ static void fill_person(struct interp *table, const char *msg, int len)
778 tz = -tz;
779 }
780
781 - interp_set_entry(table, 2, show_date(date, tz, 0));
782 - interp_set_entry(table, 3, show_rfc2822_date(date, tz));
783 - interp_set_entry(table, 4, show_date(date, tz, 1));
781 + interp_set_entry(table, 2, show_date(date, tz, DATE_NORMAL));
782 + interp_set_entry(table, 3, show_date(date, tz, DATE_RFC2822));
783 + interp_set_entry(table, 4, show_date(date, tz, DATE_RELATIVE));
784 interp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));
785 }
786
date.c
+5 -15
@@ -144,6 +144,11 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
144 tm->tm_mday,
145 tm->tm_hour, tm->tm_min, tm->tm_sec,
146 tz);
147 + else if (mode == DATE_RFC2822)
148 + sprintf(timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d",
149 + weekday_names[tm->tm_wday], tm->tm_mday,
150 + month_names[tm->tm_mon], tm->tm_year + 1900,
151 + tm->tm_hour, tm->tm_min, tm->tm_sec, tz);
152 else
153 sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d",
154 weekday_names[tm->tm_wday],
@@ -156,21 +161,6 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
161 return timebuf;
162 }
163
159 -const char *show_rfc2822_date(unsigned long time, int tz)
160 -{
161 - struct tm *tm;
162 - static char timebuf[200];
163 -
164 - tm = time_to_tm(time, tz);
165 - if (!tm)
166 - return NULL;
167 - sprintf(timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d",
168 - weekday_names[tm->tm_wday], tm->tm_mday,
169 - month_names[tm->tm_mon], tm->tm_year + 1900,
170 - tm->tm_hour, tm->tm_min, tm->tm_sec, tz);
171 - return timebuf;
172 -}
173 -
164 /*
165 * Check these. And note how it doesn't do the summer-time conversion.
166 *
refs.c
+2 -2
@@ -1300,7 +1300,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
1300 if (hashcmp(logged_sha1, sha1)) {
1301 fprintf(stderr,
1302 "warning: Log %s has gap after %s.\n",
1303 - logfile, show_rfc2822_date(date, tz));
1303 + logfile, show_date(date, tz, DATE_RFC2822));
1304 }
1305 }
1306 else if (date == at_time) {
@@ -1313,7 +1313,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
1313 if (hashcmp(logged_sha1, sha1)) {
1314 fprintf(stderr,
1315 "warning: Log %s unexpectedly ended on %s.\n",
1316 - logfile, show_rfc2822_date(date, tz));
1316 + logfile, show_date(date, tz, DATE_RFC2822));
1317 }
1318 }
1319 munmap(log_mapped, mapsz);
sha1_name.c
+1 -1
@@ -370,7 +370,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
370 fprintf(stderr,
371 "warning: Log for '%.*s' only goes "
372 "back to %s.\n", len, str,
373 - show_rfc2822_date(co_time, co_tz));
373 + show_date(co_time, co_tz, DATE_RFC2822));
374 else
375 fprintf(stderr,
376 "warning: Log for '%.*s' only has "