Teach "git log" and friends a new "--date=format:..." option to
format timestamps using system's strftime(3).
* jk/date-mode-format:
strbuf: make strbuf_addftime more robust
introduce "format" date-mode
convert "enum date_mode" into a struct
show-branch: use DATE_RELATIVE instead of magic number
const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
{
struct tm *tm;
static struct strbuf timebuf = STRBUF_INIT;
if (mode == DATE_RAW) {
if (mode->type == DATE_RAW) {
strbuf_reset(&timebuf);
strbuf_addf(&timebuf, "%lu %+05d", time, tz);
return timebuf.buf;
}
if (mode == DATE_RELATIVE) {
if (mode->type == DATE_RELATIVE) {
struct timeval now;
strbuf_reset(&timebuf);
@ -180,7 +189,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
@@ -180,7 +189,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
return timebuf.buf;
}
if (mode == DATE_LOCAL)
if (mode->type == DATE_LOCAL)
tz = local_tzoffset(time);
tm = time_to_tm(time, tz);
@ -190,17 +199,17 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
@@ -190,17 +199,17 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
@ -209,11 +218,13 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
@@ -209,11 +218,13 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
@ -221,7 +232,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
@@ -221,7 +232,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)