diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-09-19 11:38:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-19 11:38:32 -0700 |
commit | ceeacc501bc64dcdff180a9250bf2fcea3582837 (patch) | |
tree | 5934e97fc45082bc333c21e7dac5ca936112306a /date.c | |
parent | Merge branch 'mb/build-contrib-svn-fe' (diff) | |
parent | pretty: provide a strict ISO 8601 date format (diff) | |
download | tgif-ceeacc501bc64dcdff180a9250bf2fcea3582837.tar.xz |
Merge branch 'bb/date-iso-strict'
"log --date=iso" uses a slight variant of ISO 8601 format that is
made more human readable. A new "--date=iso-strict" option gives
datetime output that is more strictly conformant.
* bb/date-iso-strict:
pretty: provide a strict ISO 8601 date format
Diffstat (limited to 'date.c')
-rw-r--r-- | date.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -200,7 +200,16 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode) tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tz); - else if (mode == DATE_RFC2822) + else if (mode == DATE_ISO8601_STRICT) { + char sign = (tz >= 0) ? '+' : '-'; + tz = abs(tz); + strbuf_addf(&timebuf, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", + tm->tm_year + 1900, + tm->tm_mon + 1, + tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, + sign, tz / 100, tz % 100); + } else if (mode == DATE_RFC2822) strbuf_addf(&timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d", weekday_names[tm->tm_wday], tm->tm_mday, month_names[tm->tm_mon], tm->tm_year + 1900, @@ -751,6 +760,9 @@ enum date_mode parse_date_format(const char *format) else if (!strcmp(format, "iso8601") || !strcmp(format, "iso")) return DATE_ISO8601; + else if (!strcmp(format, "iso8601-strict") || + !strcmp(format, "iso-strict")) + return DATE_ISO8601_STRICT; else if (!strcmp(format, "rfc2822") || !strcmp(format, "rfc")) return DATE_RFC2822; |