{"thread":{"id":"9025","subject":"[PATCH] Support output ISO 8601 format dates","startedAt":"2007-07-13T20:22:58Z","lastAt":"2007-07-15T23:57:39Z","messageCount":13,"participants":["Robin Rosenberg","Junio C Hamano","Jan-Benedict Glaw","Jan Hudec","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"47286","messageId":"20070713202258.14107.18196.stgit@lathund.dewire.com","threadId":"9025","inReplyTo":null,"subject":"[PATCH] Support output ISO 8601 format dates","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-07-13T20:22:58Z","receivedAt":"2007-07-13T20:22:58Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Support output of full ISO 8601 style dates in e.g. git log\nand other places that use interpolation for formatting.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n\n cache.h  |    2 +-\n commit.c |    6 +++++-\n date.c   |    7 +++++++\n 3 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 5dff2f1..3dc0def 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -389,7 +389,7 @@ extern void *read_object_with_reference(const unsigned char *sha1,\n \t\t\t\t\tunsigned long *size,\n \t\t\t\t\tunsigned char *sha1_ret);\n \n-enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL };\n+enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL, DATE_ISO8601 };\n const char *show_date(unsigned long time, int timezone, enum date_mode mode);\n const char *show_rfc2822_date(unsigned long time, int timezone);\n int parse_date(const char *date, char *buf, int bufsize);\ndiff --git a/commit.c b/commit.c\nindex 5632e32..68df3b4 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -773,6 +773,7 @@ static void fill_person(struct interp *table, const char *msg, int len)\n \tinterp_set_entry(table, 2, show_date(date, tz, 0));\n \tinterp_set_entry(table, 3, show_rfc2822_date(date, tz));\n \tinterp_set_entry(table, 4, show_date(date, tz, 1));\n+\tinterp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));\n }\n \n static long format_commit_message(const struct commit *commit,\n@@ -791,12 +792,14 @@ static long format_commit_message(const struct commit *commit,\n \t\t{ \"%aD\" },\t/* author date, RFC2822 style */\n \t\t{ \"%ar\" },\t/* author date, relative */\n \t\t{ \"%at\" },\t/* author date, UNIX timestamp */\n+\t\t{ \"%ai\" },\t/* author date, ISO 8601 */\n \t\t{ \"%cn\" },\t/* committer name */\n \t\t{ \"%ce\" },\t/* committer email */\n \t\t{ \"%cd\" },\t/* committer date */\n \t\t{ \"%cD\" },\t/* committer date, RFC2822 style */\n \t\t{ \"%cr\" },\t/* committer date, relative */\n \t\t{ \"%ct\" },\t/* committer date, UNIX timestamp */\n+\t\t{ \"%ci\" },\t/* committer date, ISO 8601 */\n \t\t{ \"%e\" },\t/* encoding */\n \t\t{ \"%s\" },\t/* subject */\n \t\t{ \"%b\" },\t/* body */\n@@ -813,10 +816,11 @@ static long format_commit_message(const struct commit *commit,\n \t\tIPARENTS, IPARENTS_ABBREV,\n \t\tIAUTHOR_NAME, IAUTHOR_EMAIL,\n \t\tIAUTHOR_DATE, IAUTHOR_DATE_RFC2822, IAUTHOR_DATE_RELATIVE,\n-\t\tIAUTHOR_TIMESTAMP,\n+\t\tIAUTHOR_TIMESTAMP, IAUTHOR_ISO8601,\n \t\tICOMMITTER_NAME, ICOMMITTER_EMAIL,\n \t\tICOMMITTER_DATE, ICOMMITTER_DATE_RFC2822,\n \t\tICOMMITTER_DATE_RELATIVE, ICOMMITTER_TIMESTAMP,\n+\t\tICOMMITTER_ISO8601,\n \t\tIENCODING,\n \t\tISUBJECT,\n \t\tIBODY,\ndiff --git a/date.c b/date.c\nindex 4690371..5155bb2 100644\n--- a/date.c\n+++ b/date.c\n@@ -137,6 +137,13 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \tif (mode == DATE_SHORT)\n \t\tsprintf(timebuf, \"%04d-%02d-%02d\", tm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1, tm->tm_mday);\n+\telse if (mode == DATE_ISO8601)\n+\t\tsprintf(timebuf, \"%04d-%02d-%02d %02d:%02d:%02d %+05d\",\n+\t\t\t\ttm->tm_year + 1900,\n+\t\t\t\ttm->tm_mon + 1,\n+\t\t\t\ttm->tm_mday,\n+\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n+\t\t\t\ttz);\n \telse\n \t\tsprintf(timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d\",\n \t\t\t\tweekday_names[tm->tm_wday],\n"},{"id":"47289","messageId":"7vy7hklzsf.fsf@assigned-by-dhcp.cox.net","threadId":"9025","inReplyTo":"20070713202258.14107.18196.stgit@lathund.dewire.com","subject":"Re: [PATCH] Support output ISO 8601 format dates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-13T22:11:28Z","receivedAt":"2007-07-13T22:11:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Documentation/pretty-formats.txt does not talk about this\naddition.\n\nAlmost everything else looks fine with your patch, except that\nneither \"git show --date=iso\" nor \"git log --date=iso8601\" works\nwith this change, but that is only half your fault.\n\nWhen we added DATE_SHORT support we could have added the option\nparser to revision.c so that you could mimick it more easily.\nThat half is my fault.\n\nThe patch, especially this hunk:\n\n> diff --git a/commit.c b/commit.c\n> index 5632e32..68df3b4 100644\n> --- a/commit.c\n> +++ b/commit.c\n> @@ -773,6 +773,7 @@ static void fill_person(struct interp *table, const char *msg, int len)\n>  \tinterp_set_entry(table, 2, show_date(date, tz, 0));\n>  \tinterp_set_entry(table, 3, show_rfc2822_date(date, tz));\n>  \tinterp_set_entry(table, 4, show_date(date, tz, 1));\n> +\tinterp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));\n>  }\n>  \n>  static long format_commit_message(const struct commit *commit,\n\nmakes me wonder if we would want to refactor and reimplement\nshow_rfc2822_date() in terms of show_date(), by introducing\nDATE_RFC2822 in the date format enum, which will allow us to say\n\"git show --date=rfc2822\".\n\nHmm?\n"},{"id":"47292","messageId":"20070713225836.17922.32546.stgit@lathund.dewire.com","threadId":"9025","inReplyTo":"7vy7hklzsf.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Support output ISO 8601 format dates","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-07-13T23:00:42Z","receivedAt":"2007-07-13T23:00:42Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Support output of full ISO 8601 style dates in e.g. git log\nand other places that use interpolation for formatting.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n\nUpdated docs too. The show --date is not included because I didn't know\nabout it.\n\n Documentation/pretty-formats.txt |    2 ++\n cache.h                          |    2 +-\n commit.c                         |    6 +++++-\n date.c                           |    7 +++++++\n 4 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex d922e8e..1296b31 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -106,12 +106,14 @@ The placeholders are:\n - '%aD': author date, RFC2822 style\n - '%ar': author date, relative\n - '%at': author date, UNIX timestamp\n+- '%ai': author date, ISO 8601 format\n - '%cn': committer name\n - '%ce': committer email\n - '%cd': committer date\n - '%cD': committer date, RFC2822 style\n - '%cr': committer date, relative\n - '%ct': committer date, UNIX timestamp\n+- '%ci': committer date, ISO 8601 format\n - '%e': encoding\n - '%s': subject\n - '%b': body\ndiff --git a/cache.h b/cache.h\nindex 5dff2f1..3dc0def 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -389,7 +389,7 @@ extern void *read_object_with_reference(const unsigned char *sha1,\n \t\t\t\t\tunsigned long *size,\n \t\t\t\t\tunsigned char *sha1_ret);\n \n-enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL };\n+enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL, DATE_ISO8601 };\n const char *show_date(unsigned long time, int timezone, enum date_mode mode);\n const char *show_rfc2822_date(unsigned long time, int timezone);\n int parse_date(const char *date, char *buf, int bufsize);\ndiff --git a/commit.c b/commit.c\nindex 5632e32..68df3b4 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -773,6 +773,7 @@ static void fill_person(struct interp *table, const char *msg, int len)\n \tinterp_set_entry(table, 2, show_date(date, tz, 0));\n \tinterp_set_entry(table, 3, show_rfc2822_date(date, tz));\n \tinterp_set_entry(table, 4, show_date(date, tz, 1));\n+\tinterp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));\n }\n \n static long format_commit_message(const struct commit *commit,\n@@ -791,12 +792,14 @@ static long format_commit_message(const struct commit *commit,\n \t\t{ \"%aD\" },\t/* author date, RFC2822 style */\n \t\t{ \"%ar\" },\t/* author date, relative */\n \t\t{ \"%at\" },\t/* author date, UNIX timestamp */\n+\t\t{ \"%ai\" },\t/* author date, ISO 8601 */\n \t\t{ \"%cn\" },\t/* committer name */\n \t\t{ \"%ce\" },\t/* committer email */\n \t\t{ \"%cd\" },\t/* committer date */\n \t\t{ \"%cD\" },\t/* committer date, RFC2822 style */\n \t\t{ \"%cr\" },\t/* committer date, relative */\n \t\t{ \"%ct\" },\t/* committer date, UNIX timestamp */\n+\t\t{ \"%ci\" },\t/* committer date, ISO 8601 */\n \t\t{ \"%e\" },\t/* encoding */\n \t\t{ \"%s\" },\t/* subject */\n \t\t{ \"%b\" },\t/* body */\n@@ -813,10 +816,11 @@ static long format_commit_message(const struct commit *commit,\n \t\tIPARENTS, IPARENTS_ABBREV,\n \t\tIAUTHOR_NAME, IAUTHOR_EMAIL,\n \t\tIAUTHOR_DATE, IAUTHOR_DATE_RFC2822, IAUTHOR_DATE_RELATIVE,\n-\t\tIAUTHOR_TIMESTAMP,\n+\t\tIAUTHOR_TIMESTAMP, IAUTHOR_ISO8601,\n \t\tICOMMITTER_NAME, ICOMMITTER_EMAIL,\n \t\tICOMMITTER_DATE, ICOMMITTER_DATE_RFC2822,\n \t\tICOMMITTER_DATE_RELATIVE, ICOMMITTER_TIMESTAMP,\n+\t\tICOMMITTER_ISO8601,\n \t\tIENCODING,\n \t\tISUBJECT,\n \t\tIBODY,\ndiff --git a/date.c b/date.c\nindex 4690371..5155bb2 100644\n--- a/date.c\n+++ b/date.c\n@@ -137,6 +137,13 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \tif (mode == DATE_SHORT)\n \t\tsprintf(timebuf, \"%04d-%02d-%02d\", tm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1, tm->tm_mday);\n+\telse if (mode == DATE_ISO8601)\n+\t\tsprintf(timebuf, \"%04d-%02d-%02d %02d:%02d:%02d %+05d\",\n+\t\t\t\ttm->tm_year + 1900,\n+\t\t\t\ttm->tm_mon + 1,\n+\t\t\t\ttm->tm_mday,\n+\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n+\t\t\t\ttz);\n \telse\n \t\tsprintf(timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d\",\n \t\t\t\tweekday_names[tm->tm_wday],\n"},{"id":"47316","messageId":"7vsl7rlc4e.fsf_-_@assigned-by-dhcp.cox.net","threadId":"9025","inReplyTo":"20070713225836.17922.32546.stgit@lathund.dewire.com","subject":"[PATCH 1/2] Make show_rfc2822_date() just another date output format.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-14T06:42:41Z","receivedAt":"2007-07-14T06:42:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"These days, show_date() takes a date_mode parameter to specify\nthe output format, and a separate specialized function for dates\nin E-mails does not make much sense anymore.\n\nThis retires show_rfc2822_date() function and make it just\nanother date output format.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n\n > Updated docs too. The show --date is not included because I didn't know\n > about it.\n\n Thanks.  Here is what I had in mind when I \"wondered\" aloud earlier...\n\n cache.h     |   11 +++++++++--\n commit.c    |    8 ++++----\n date.c      |   20 +++++---------------\n refs.c      |    4 ++--\n sha1_name.c |    2 +-\n 5 files changed, 21 insertions(+), 24 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex b39557d..328c1ad 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -409,9 +409,16 @@ extern void *read_object_with_reference(const unsigned char *sha1,\n \t\t\t\t\tunsigned long *size,\n \t\t\t\t\tunsigned char *sha1_ret);\n \n-enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL, DATE_ISO8601 };\n+enum date_mode {\n+\tDATE_NORMAL = 0,\n+\tDATE_RELATIVE,\n+\tDATE_SHORT,\n+\tDATE_LOCAL,\n+\tDATE_ISO8601,\n+\tDATE_RFC2822\n+};\n+\n const char *show_date(unsigned long time, int timezone, enum date_mode mode);\n-const char *show_rfc2822_date(unsigned long time, int timezone);\n int parse_date(const char *date, char *buf, int bufsize);\n void datestamp(char *buf, int bufsize);\n unsigned long approxidate(const char *);\ndiff --git a/commit.c b/commit.c\nindex d11941c..4c5dfa9 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -585,7 +585,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,\n \t\tbreak;\n \tcase CMIT_FMT_EMAIL:\n \t\tret += sprintf(buf + ret, \"Date: %s\\n\",\n-\t\t\t       show_rfc2822_date(time, tz));\n+\t\t\t       show_date(time, tz, DATE_RFC2822));\n \t\tbreak;\n \tcase CMIT_FMT_FULLER:\n \t\tret += sprintf(buf + ret, \"%sDate: %s\\n\", what,\n@@ -778,9 +778,9 @@ static void fill_person(struct interp *table, const char *msg, int len)\n \t\t\ttz = -tz;\n \t}\n \n-\tinterp_set_entry(table, 2, show_date(date, tz, 0));\n-\tinterp_set_entry(table, 3, show_rfc2822_date(date, tz));\n-\tinterp_set_entry(table, 4, show_date(date, tz, 1));\n+\tinterp_set_entry(table, 2, show_date(date, tz, DATE_NORMAL));\n+\tinterp_set_entry(table, 3, show_date(date, tz, DATE_RFC2822));\n+\tinterp_set_entry(table, 4, show_date(date, tz, DATE_RELATIVE));\n \tinterp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));\n }\n \ndiff --git a/date.c b/date.c\nindex 735d8f3..45b0b1d 100644\n--- a/date.c\n+++ b/date.c\n@@ -144,6 +144,11 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \t\t\t\ttm->tm_mday,\n \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n \t\t\t\ttz);\n+\telse if (mode == DATE_RFC2822)\n+\t\tsprintf(timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n+\t\t\tweekday_names[tm->tm_wday], tm->tm_mday,\n+\t\t\tmonth_names[tm->tm_mon], tm->tm_year + 1900,\n+\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec, tz);\n \telse\n \t\tsprintf(timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d\",\n \t\t\t\tweekday_names[tm->tm_wday],\n@@ -156,21 +161,6 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \treturn timebuf;\n }\n \n-const char *show_rfc2822_date(unsigned long time, int tz)\n-{\n-\tstruct tm *tm;\n-\tstatic char timebuf[200];\n-\n-\ttm = time_to_tm(time, tz);\n-\tif (!tm)\n-\t\treturn NULL;\n-\tsprintf(timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n-\t\tweekday_names[tm->tm_wday], tm->tm_mday,\n-\t\tmonth_names[tm->tm_mon], tm->tm_year + 1900,\n-\t\ttm->tm_hour, tm->tm_min, tm->tm_sec, tz);\n-\treturn timebuf;\n-}\n-\n /*\n  * Check these. And note how it doesn't do the summer-time conversion.\n  *\ndiff --git a/refs.c b/refs.c\nindex 4dc7e8b..2694e70 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1300,7 +1300,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *\n \t\t\t\tif (hashcmp(logged_sha1, sha1)) {\n \t\t\t\t\tfprintf(stderr,\n \t\t\t\t\t\t\"warning: Log %s has gap after %s.\\n\",\n-\t\t\t\t\t\tlogfile, show_rfc2822_date(date, tz));\n+\t\t\t\t\t\tlogfile, show_date(date, tz, DATE_RFC2822));\n \t\t\t\t}\n \t\t\t}\n \t\t\telse if (date == at_time) {\n@@ -1313,7 +1313,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *\n \t\t\t\tif (hashcmp(logged_sha1, sha1)) {\n \t\t\t\t\tfprintf(stderr,\n \t\t\t\t\t\t\"warning: Log %s unexpectedly ended on %s.\\n\",\n-\t\t\t\t\t\tlogfile, show_rfc2822_date(date, tz));\n+\t\t\t\t\t\tlogfile, show_date(date, tz, DATE_RFC2822));\n \t\t\t\t}\n \t\t\t}\n \t\t\tmunmap(log_mapped, mapsz);\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 858f08c..2d727d5 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -370,7 +370,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \t\t\t\tfprintf(stderr,\n \t\t\t\t\t\"warning: Log for '%.*s' only goes \"\n \t\t\t\t\t\"back to %s.\\n\", len, str,\n-\t\t\t\t\tshow_rfc2822_date(co_time, co_tz));\n+\t\t\t\t\tshow_date(co_time, co_tz, DATE_RFC2822));\n \t\t\telse\n \t\t\t\tfprintf(stderr,\n \t\t\t\t\t\"warning: Log for '%.*s' only has \"\n-- \n1.5.3.rc1.4.gaf83\n"},{"id":"47317","messageId":"7vodiflc3v.fsf_-_@assigned-by-dhcp.cox.net","threadId":"9025","inReplyTo":"20070713225836.17922.32546.stgit@lathund.dewire.com","subject":"[PATCH 2/2] Wire new date formats to --date=<format> parser.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-14T06:43:00Z","receivedAt":"2007-07-14T06:43:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Now we can use all internally supported date formats with\n\n\tgit log --date=<format>\n\nsyntax.  Earlier, we only allowed relative/local/default.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n revision.c |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 27cce09..28b5f2e 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1133,6 +1133,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\tif (!strncmp(arg, \"--date=\", 7)) {\n \t\t\t\tif (!strcmp(arg + 7, \"relative\"))\n \t\t\t\t\trevs->date_mode = DATE_RELATIVE;\n+\t\t\t\telse if (!strcmp(arg + 7, \"iso8601\") ||\n+\t\t\t\t\t !strcmp(arg + 7, \"iso\"))\n+\t\t\t\t\trevs->date_mode = DATE_ISO8601;\n+\t\t\t\telse if (!strcmp(arg + 7, \"rfc2822\") ||\n+\t\t\t\t\t !strcmp(arg + 7, \"rfc\"))\n+\t\t\t\t\trevs->date_mode = DATE_RFC2822;\n+\t\t\t\telse if (!strcmp(arg + 7, \"short\"))\n+\t\t\t\t\trevs->date_mode = DATE_SHORT;\n \t\t\t\telse if (!strcmp(arg + 7, \"local\"))\n \t\t\t\t\trevs->date_mode = DATE_LOCAL;\n \t\t\t\telse if (!strcmp(arg + 7, \"default\"))\n-- \n1.5.3.rc1.4.gaf83\n"},{"id":"47318","messageId":"20070714064451.GH11809@lug-owl.de","threadId":"9025","inReplyTo":"7vodiflc3v.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/2] Wire new date formats to --date=<format> parser.","fromName":"Jan-Benedict Glaw","fromEmail":"jbglaw@lug-owl.de","sentAt":"2007-07-14T06:44:51Z","receivedAt":"2007-07-14T06:44:51Z","isPatch":true,"sender":{"key":"jbglaw@lug-owl.de","avatar":null},"body":"On Fri, 2007-07-13 23:43:00 -0700, Junio C Hamano <gitster@pobox.com> wrote:\n> --- a/revision.c\n> +++ b/revision.c\n> @@ -1133,6 +1133,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n>  \t\t\tif (!strncmp(arg, \"--date=\", 7)) {\n>  \t\t\t\tif (!strcmp(arg + 7, \"relative\"))\n>  \t\t\t\t\trevs->date_mode = DATE_RELATIVE;\n> +\t\t\t\telse if (!strcmp(arg + 7, \"iso8601\") ||\n> +\t\t\t\t\t !strcmp(arg + 7, \"iso\"))\n> +\t\t\t\t\trevs->date_mode = DATE_ISO8601;\n> +\t\t\t\telse if (!strcmp(arg + 7, \"rfc2822\") ||\n> +\t\t\t\t\t !strcmp(arg + 7, \"rfc\"))\n\nMaybe also add \"rfc822\"?\n\n> +\t\t\t\t\trevs->date_mode = DATE_RFC2822;\n> +\t\t\t\telse if (!strcmp(arg + 7, \"short\"))\n> +\t\t\t\t\trevs->date_mode = DATE_SHORT;\n>  \t\t\t\telse if (!strcmp(arg + 7, \"local\"))\n>  \t\t\t\t\trevs->date_mode = DATE_LOCAL;\n>  \t\t\t\telse if (!strcmp(arg + 7, \"default\"))\n\nMfG, JBG\n\n-- \n      Jan-Benedict Glaw      jbglaw@lug-owl.de              +49-172-7608481\nSignature of:            http://www.chiark.greenend.org.uk/~sgtatham/bugs.html\nthe second  :\n"},{"id":"47319","messageId":"7vk5t3lbtj.fsf_-_@assigned-by-dhcp.cox.net","threadId":"9025","inReplyTo":"20070713225836.17922.32546.stgit@lathund.dewire.com","subject":"[PATCH] Document new --date=<format>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-14T06:49:12Z","receivedAt":"2007-07-14T06:49:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Now, git-log family can take full range of internally supported date format\nto their --date=<format> argument.  Document it.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n * And the documentation...\n\n Documentation/git-rev-list.txt |   11 +++++++++--\n 1 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\nindex 20dcac6..08e7573 100644\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -28,7 +28,7 @@ SYNOPSIS\n \t     [ \\--encoding[=<encoding>] ]\n \t     [ \\--(author|committer|grep)=<pattern> ]\n \t     [ \\--regexp-ignore-case ] [ \\--extended-regexp ]\n-\t     [ \\--date={local|relative|default} ]\n+\t     [ \\--date={local|relative|default|iso|rfc|short} ]\n \t     [ [\\--objects | \\--objects-edge] [ \\--unpacked ] ]\n \t     [ \\--pretty | \\--header ]\n \t     [ \\--bisect ]\n@@ -96,7 +96,7 @@ include::pretty-options.txt[]\n \n \tSynonym for `--date=relative`.\n \n---date={relative,local,default}::\n+--date={relative,local,default,iso,rfc}::\n \n \tOnly takes effect for dates shown in human-readable format, such\n \tas when using \"--pretty\".\n@@ -106,6 +106,13 @@ e.g. \"2 hours ago\".\n +\n `--date=local` shows timestamps in user's local timezone.\n +\n+`--date=iso` (or `--date=iso8601`) shows timestamps in ISO 8601 format.\n++\n+`--date=rfc` (or `--date=rfc2822`) shows timestamps in RFC 2822\n+format, often found in E-mail messages.\n++\n+`--date=short` shows only date but not time, in `YYYY-MM-DD` fomat.\n++\n `--date=default` shows timestamps in the original timezone\n (either committer's or author's).\n \n-- \n1.5.3.rc1.4.gaf83\n"},{"id":"47321","messageId":"7vbqeflbl0.fsf@assigned-by-dhcp.cox.net","threadId":"9025","inReplyTo":"20070714064451.GH11809@lug-owl.de","subject":"Re: [PATCH 2/2] Wire new date formats to --date=<format> parser.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-14T06:54:19Z","receivedAt":"2007-07-14T06:54:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan-Benedict Glaw <jbglaw@lug-owl.de> writes:\n\n> On Fri, 2007-07-13 23:43:00 -0700, Junio C Hamano <gitster@pobox.com> wrote:\n>> --- a/revision.c\n>> +++ b/revision.c\n>> @@ -1133,6 +1133,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n>>  \t\t\tif (!strncmp(arg, \"--date=\", 7)) {\n>>  \t\t\t\tif (!strcmp(arg + 7, \"relative\"))\n>>  \t\t\t\t\trevs->date_mode = DATE_RELATIVE;\n>> +\t\t\t\telse if (!strcmp(arg + 7, \"iso8601\") ||\n>> +\t\t\t\t\t !strcmp(arg + 7, \"iso\"))\n>> +\t\t\t\t\trevs->date_mode = DATE_ISO8601;\n>> +\t\t\t\telse if (!strcmp(arg + 7, \"rfc2822\") ||\n>> +\t\t\t\t\t !strcmp(arg + 7, \"rfc\"))\n>\n> Maybe also add \"rfc822\"?\n\nI've thought about it, but did not bother; I suspect people would\njust say \"rfc\" anyway.\n"},{"id":"47351","messageId":"200707141229.27668.robin.rosenberg@dewire.com","threadId":"9025","inReplyTo":"7vodiflc3v.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/2] Wire new date formats to --date=<format> parser.","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-07-14T10:29:27Z","receivedAt":"2007-07-14T10:29:27Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"lördag 14 juli 2007 skrev Junio C Hamano:\n> Now we can use all internally supported date formats with\n> \n> \tgit log --date=<format>\n> \n> syntax.  Earlier, we only allowed relative/local/default.\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nAck, 1/2 and 2/2.\n\n-- robin\n"},{"id":"47457","messageId":"20070715212359.GB18293@efreet.light.src","threadId":"9025","inReplyTo":"20070713202258.14107.18196.stgit@lathund.dewire.com","subject":"Re: [PATCH] Support output ISO 8601 format dates","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-07-15T21:23:59Z","receivedAt":"2007-07-15T21:23:59Z","isPatch":true,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"Hello,\n\nOn Fri, Jul 13, 2007 at 22:22:58 +0200, Robin Rosenberg wrote:\n> +\telse if (mode == DATE_ISO8601)\n> +\t\tsprintf(timebuf, \"%04d-%02d-%02d %02d:%02d:%02d %+05d\",\n> +\t\t\t\ttm->tm_year + 1900,\n> +\t\t\t\ttm->tm_mon + 1,\n> +\t\t\t\ttm->tm_mday,\n> +\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n> +\t\t\t\ttz);\n\nI apologise for nitpicking, but ISO 8601 (and RFC 3339) says separator between\ndate and time is 'T' and there is no separator between time and timezone. So\nthis should be\n\n+\t\tsprintf(timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%+05d\",\n\nfor 100% conformance to the standard. RFC 3339 explicitely mentions using\nspace instead of 'T' as separator as allowed, but does not seem to mention\nspace before time zone. There may be applications that would stop at such\nspace and assume no timezone information.\n\nFurthermore RFC 3339 seems to require colon in the timezone, so it would be:\n\n+\t\tsprintf(timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%+03d:%02d\",\n+\t\t\t\ttm->tm_year + 1900,\n+\t\t\t\ttm->tm_mon + 1,\n+\t\t\t\ttm->tm_mday,\n+\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n+\t\t\t\ttz / 100, abs(tz % 100));\n\nISO 8601 makes separators optional, so simple 4-digit timezone is OK.\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"},{"id":"47464","messageId":"7vveclco10.fsf@assigned-by-dhcp.cox.net","threadId":"9025","inReplyTo":"20070715212359.GB18293@efreet.light.src","subject":"Re: [PATCH] Support output ISO 8601 format dates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-15T22:14:51Z","receivedAt":"2007-07-15T22:14:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan Hudec <bulb@ucw.cz> writes:\n\n> I apologise for nitpicking, but ISO 8601 (and RFC 3339) says separator between\n> date and time is 'T' and there is no separator between time and timezone. So\n> this should be\n> ...\n> ISO 8601 makes separators optional, so simple 4-digit timezone is OK.\n\nMy reading of 8601 was that it is allowed to drop [T] as long as\nit is clear from the context by agreement between the parties\ninvolved, although I admit the only copy I have handy is JIS\nX0301 (2002), which is matching Japanese industrial standard\nthat consists of translation of ISO 8601 (2000) plus Japanese\n\"emperor's era\" extensions.\n"},{"id":"47469","messageId":"200707160119.34509.robin.rosenberg@dewire.com","threadId":"9025","inReplyTo":"20070715212359.GB18293@efreet.light.src","subject":"Re: [PATCH] Support output ISO 8601 format dates","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-07-15T23:19:33Z","receivedAt":"2007-07-15T23:19:33Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"From 59eafc201aec3be121b33c2ecf16c70cc3521e92 Mon Sep 17 00:00:00 2001\nFrom: Robin Rosenberg <robin.rosenberg@dewire.com>\nDate: Mon, 16 Jul 2007 01:05:19 +0200\nSubject: [PATCH] Support output ISO 8601 format dates\n\nSupport output of full ISO 8601 style dates in e.g. git log\nand other places that use interpolation for formatting.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n Documentation/pretty-formats.txt |    2 ++\n cache.h                          |    2 +-\n commit.c                         |    6 +++++-\n date.c                           |    9 +++++++++\n 4 files changed, 17 insertions(+), 2 deletions(-)\n\nsöndag 15 juli 2007 skrev Jan Hudec:\n> Hello,\n> \n> On Fri, Jul 13, 2007 at 22:22:58 +0200, Robin Rosenberg wrote:\n> > +\telse if (mode == DATE_ISO8601)\n> > +\t\tsprintf(timebuf, \"%04d-%02d-%02d %02d:%02d:%02d %+05d\",\n> > +\t\t\t\ttm->tm_year + 1900,\n> > +\t\t\t\ttm->tm_mon + 1,\n> > +\t\t\t\ttm->tm_mday,\n> > +\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n> > +\t\t\t\ttz);\n> \n> I apologise for nitpicking, but ISO 8601 (and RFC 3339) says separator between\n> date and time is 'T' and there is no separator between time and timezone. So\n> this should be\n> \n> +\t\tsprintf(timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%+05d\",\n\nNote that my reference is to ISO 8601, not RFC 3339.  Hower I interpret \"NOTE By mutual \nagreement of the partners in information interchange, the character [T] may be omitted in\napplications where there is no risk of confusing a date and time of day representation with\nothers defined in this International Standard\" (ISO 8601:2004 4.3.2) as space being\nallowed here instead of 'T'.\n\nBy \"mutual agreement\" I mean that I tell you what it looks like and you agree :)\n\nI agree with you about the space before timezone though. I'll go.\n\n> for 100% conformance to the standard. RFC 3339 explicitely mentions using\n> space instead of 'T' as separator as allowed, but does not seem to mention\n> space before time zone. There may be applications that would stop at such\n> space and assume no timezone information.\n> \n> Furthermore RFC 3339 seems to require colon in the timezone, so it would be:\n> \n> +\t\tsprintf(timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%+03d:%02d\",\n> +\t\t\t\ttm->tm_year + 1900,\n> +\t\t\t\ttm->tm_mon + 1,\n> +\t\t\t\ttm->tm_mday,\n> +\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n> +\t\t\t\ttz / 100, abs(tz % 100));\n> \n> ISO 8601 makes separators optional, so simple 4-digit timezone is OK.\n\nFor the sake of consequence I should use the extended format for all parts and not mix\nbasic and extended formats.\n\nUpdated patch follows that formats dates as \"2006-08-17 20:59:46+05:30\"\n\n-- robin\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex d922e8e..1296b31 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -106,12 +106,14 @@ The placeholders are:\n - '%aD': author date, RFC2822 style\n - '%ar': author date, relative\n - '%at': author date, UNIX timestamp\n+- '%ai': author date, ISO 8601 format\n - '%cn': committer name\n - '%ce': committer email\n - '%cd': committer date\n - '%cD': committer date, RFC2822 style\n - '%cr': committer date, relative\n - '%ct': committer date, UNIX timestamp\n+- '%ci': committer date, ISO 8601 format\n - '%e': encoding\n - '%s': subject\n - '%b': body\ndiff --git a/cache.h b/cache.h\nindex 5dff2f1..3dc0def 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -389,7 +389,7 @@ extern void *read_object_with_reference(const unsigned char *sha1,\n \t\t\t\t\tunsigned long *size,\n \t\t\t\t\tunsigned char *sha1_ret);\n \n-enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL };\n+enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL, DATE_ISO8601 };\n const char *show_date(unsigned long time, int timezone, enum date_mode mode);\n const char *show_rfc2822_date(unsigned long time, int timezone);\n int parse_date(const char *date, char *buf, int bufsize);\ndiff --git a/commit.c b/commit.c\nindex 5632e32..68df3b4 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -773,6 +773,7 @@ static void fill_person(struct interp *table, const char *msg, int len)\n \tinterp_set_entry(table, 2, show_date(date, tz, 0));\n \tinterp_set_entry(table, 3, show_rfc2822_date(date, tz));\n \tinterp_set_entry(table, 4, show_date(date, tz, 1));\n+\tinterp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));\n }\n \n static long format_commit_message(const struct commit *commit,\n@@ -791,12 +792,14 @@ static long format_commit_message(const struct commit *commit,\n \t\t{ \"%aD\" },\t/* author date, RFC2822 style */\n \t\t{ \"%ar\" },\t/* author date, relative */\n \t\t{ \"%at\" },\t/* author date, UNIX timestamp */\n+\t\t{ \"%ai\" },\t/* author date, ISO 8601 */\n \t\t{ \"%cn\" },\t/* committer name */\n \t\t{ \"%ce\" },\t/* committer email */\n \t\t{ \"%cd\" },\t/* committer date */\n \t\t{ \"%cD\" },\t/* committer date, RFC2822 style */\n \t\t{ \"%cr\" },\t/* committer date, relative */\n \t\t{ \"%ct\" },\t/* committer date, UNIX timestamp */\n+\t\t{ \"%ci\" },\t/* committer date, ISO 8601 */\n \t\t{ \"%e\" },\t/* encoding */\n \t\t{ \"%s\" },\t/* subject */\n \t\t{ \"%b\" },\t/* body */\n@@ -813,10 +816,11 @@ static long format_commit_message(const struct commit *commit,\n \t\tIPARENTS, IPARENTS_ABBREV,\n \t\tIAUTHOR_NAME, IAUTHOR_EMAIL,\n \t\tIAUTHOR_DATE, IAUTHOR_DATE_RFC2822, IAUTHOR_DATE_RELATIVE,\n-\t\tIAUTHOR_TIMESTAMP,\n+\t\tIAUTHOR_TIMESTAMP, IAUTHOR_ISO8601,\n \t\tICOMMITTER_NAME, ICOMMITTER_EMAIL,\n \t\tICOMMITTER_DATE, ICOMMITTER_DATE_RFC2822,\n \t\tICOMMITTER_DATE_RELATIVE, ICOMMITTER_TIMESTAMP,\n+\t\tICOMMITTER_ISO8601,\n \t\tIENCODING,\n \t\tISUBJECT,\n \t\tIBODY,\ndiff --git a/date.c b/date.c\nindex 4690371..c96100e 100644\n--- a/date.c\n+++ b/date.c\n@@ -137,7 +137,15 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \tif (mode == DATE_SHORT)\n \t\tsprintf(timebuf, \"%04d-%02d-%02d\", tm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1, tm->tm_mday);\n+\telse if (mode == DATE_ISO8601)\n+\t\tsprintf(timebuf, \"%04d-%02d-%02d %02d:%02d:%02d%+03d:%02d\",\n+\t\t\t\ttm->tm_year + 1900,\n+\t\t\t\ttm->tm_mon + 1,\n+\t\t\t\ttm->tm_mday,\n+\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n+\t\t\t\ttz/100,\n+\t\t\t\tabs(tz%100)\n+\t\t\t\t);\n \telse\n \t\tsprintf(timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d\",\n \t\t\t\tweekday_names[tm->tm_wday],\n-- \n1.5.2.3\n"},{"id":"47484","messageId":"alpine.LFD.0.999.0707151657230.20061@woody.linux-foundation.org","threadId":"9025","inReplyTo":"200707160119.34509.robin.rosenberg@dewire.com","subject":"Re: [PATCH] Support output ISO 8601 format dates","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-07-15T23:57:39Z","receivedAt":"2007-07-15T23:57:39Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 16 Jul 2007, Robin Rosenberg wrote:\n> \n> By \"mutual agreement\" I mean that I tell you what it looks like and you agree :)\n\nROTFL.\n\n\t\tLinus\n"}]}