{"thread":{"id":"7824","subject":"[PATCH] Add date format --local-zone","startedAt":"2007-04-25T06:36:22Z","lastAt":"2007-04-26T06:54:01Z","messageCount":12,"participants":["Junio C Hamano","Shawn O. Pearce","Johannes Schindelin","Linus Torvalds","Alex Riesen","David Kågedal"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40375","messageId":"1177482982542-git-send-email-junkio@cox.net","threadId":"7824","inReplyTo":null,"subject":"[PATCH] Add date format --local-zone","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-25T06:36:22Z","receivedAt":"2007-04-25T06:36:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This adds --local-zone option to log family of commands, to\ndisplay timestamps in user's local timezone.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * I got tired of looking at +0000 timestamps on commits\n   imported from CVS at day-job.  Does not seem to break\n   existing tests, but I am not sure if this is useful.\n\n builtin-rev-list.c |    2 +-\n cache.h            |    2 +-\n commit.c           |   12 ++++++------\n commit.h           |    2 +-\n date.c             |   31 +++++++++++++++++++++++++++++++\n log-tree.c         |    4 ++--\n revision.c         |    6 +++++-\n revision.h         |    2 +-\n 8 files changed, 48 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex c0329dc..ebf53f5 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -95,7 +95,7 @@ static void show_commit(struct commit *commit)\n \t\tstatic char pretty_header[16384];\n \t\tpretty_print_commit(revs.commit_format, commit, ~0,\n \t\t\t\t    pretty_header, sizeof(pretty_header),\n-\t\t\t\t    revs.abbrev, NULL, NULL, revs.relative_date);\n+\t\t\t\t    revs.abbrev, NULL, NULL, revs.date_mode);\n \t\tprintf(\"%s%c\", pretty_header, hdr_termination);\n \t}\n \tfflush(stdout);\ndiff --git a/cache.h b/cache.h\nindex f05b67a..6620591 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 };\n+enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL };\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 10466c4..f1ba972 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -526,7 +526,7 @@ static int add_rfc2047(char *buf, const char *line, int len,\n }\n \n static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,\n-\t\t\t const char *line, int relative_date,\n+\t\t\t const char *line, enum date_mode dmode,\n \t\t\t const char *encoding)\n {\n \tchar *date;\n@@ -569,7 +569,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,\n \tswitch (fmt) {\n \tcase CMIT_FMT_MEDIUM:\n \t\tret += sprintf(buf + ret, \"Date:   %s\\n\",\n-\t\t\t       show_date(time, tz, relative_date));\n+\t\t\t       show_date(time, tz, dmode));\n \t\tbreak;\n \tcase CMIT_FMT_EMAIL:\n \t\tret += sprintf(buf + ret, \"Date: %s\\n\",\n@@ -577,7 +577,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,\n \t\tbreak;\n \tcase CMIT_FMT_FULLER:\n \t\tret += sprintf(buf + ret, \"%sDate: %s\\n\", what,\n-\t\t\t       show_date(time, tz, relative_date));\n+\t\t\t       show_date(time, tz, dmode));\n \t\tbreak;\n \tdefault:\n \t\t/* notin' */\n@@ -919,7 +919,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,\n \t\t\t\t  char *buf, unsigned long space,\n \t\t\t\t  int abbrev, const char *subject,\n \t\t\t\t  const char *after_subject,\n-\t\t\t\t  int relative_date)\n+\t\t\t\t  enum date_mode dmode)\n {\n \tint hdr = 1, body = 0, seen_title = 0;\n \tunsigned long offset = 0;\n@@ -1023,14 +1023,14 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,\n \t\t\t\toffset += add_user_info(\"Author\", fmt,\n \t\t\t\t\t\t\tbuf + offset,\n \t\t\t\t\t\t\tline + 7,\n-\t\t\t\t\t\t\trelative_date,\n+\t\t\t\t\t\t\tdmode,\n \t\t\t\t\t\t\tencoding);\n \t\t\tif (!memcmp(line, \"committer \", 10) &&\n \t\t\t    (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER))\n \t\t\t\toffset += add_user_info(\"Commit\", fmt,\n \t\t\t\t\t\t\tbuf + offset,\n \t\t\t\t\t\t\tline + 10,\n-\t\t\t\t\t\t\trelative_date,\n+\t\t\t\t\t\t\tdmode,\n \t\t\t\t\t\t\tencoding);\n \t\t\tcontinue;\n \t\t}\ndiff --git a/commit.h b/commit.h\nindex 59de17e..86e8dca 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -61,7 +61,7 @@ enum cmit_fmt {\n };\n \n extern enum cmit_fmt get_commit_format(const char *arg);\n-extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date);\n+extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode);\n \n /** Removes the first commit from a list sorted by date, and adds all\n  * of its parents.\ndiff --git a/date.c b/date.c\nindex 0ceccbe..aa6ac33 100644\n--- a/date.c\n+++ b/date.c\n@@ -55,6 +55,34 @@ static struct tm *time_to_tm(unsigned long time, int tz)\n \treturn gmtime(&t);\n }\n \n+/*\n+ * What value of \"tz\" was in effect back then at \"time\" in the\n+ * local timezone?\n+ */\n+static int local_tzoffset(unsigned long time)\n+{\n+\ttime_t t, t_local, t_gm;\n+\tstruct tm tm;\n+\tint offset, eastwest;\n+\n+\tt = time;\n+\tlocaltime_r(&t, &tm);\n+\tt_local = my_mktime(&tm);\n+\tgmtime_r(&t, &tm);\n+\tt_gm = my_mktime(&tm);\n+\n+\tif (t_local < t_gm) {\n+\t\teastwest = -1;\n+\t\toffset = t_gm - t_local;\n+\t} else {\n+\t\teastwest = 1;\n+\t\toffset = t_local - t_gm;\n+\t}\n+\toffset /= 60; /* in minutes */\n+\toffset = (offset % 60) + ((offset / 60) * 100);\n+\treturn offset * eastwest;\n+}\n+\n const char *show_date(unsigned long time, int tz, enum date_mode mode)\n {\n \tstruct tm *tm;\n@@ -102,6 +130,9 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \t\t/* Else fall back on absolute format.. */\n \t}\n \n+\tif (mode == DATE_LOCAL)\n+\t\ttz = local_tzoffset(time);\n+\n \ttm = time_to_tm(time, tz);\n \tif (!tm)\n \t\treturn NULL;\ndiff --git a/log-tree.c b/log-tree.c\nindex 300b733..c679324 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -267,7 +267,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\tif (opt->reflog_info) {\n \t\t\tshow_reflog_message(opt->reflog_info,\n \t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n-\t\t\t\t    opt->relative_date);\n+\t\t\t\t    opt->date_mode);\n \t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n \t\t\t\tprintf(\"%s\", sep);\n \t\t\t\treturn;\n@@ -280,7 +280,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t */\n \tlen = pretty_print_commit(opt->commit_format, commit, ~0u, this_header,\n \t\t\t\t  sizeof(this_header), abbrev, subject,\n-\t\t\t\t  extra_headers, opt->relative_date);\n+\t\t\t\t  extra_headers, opt->date_mode);\n \n \tif (opt->add_signoff)\n \t\tlen = append_signoff(this_header, sizeof(this_header), len,\ndiff --git a/revision.c b/revision.c\nindex 49bd292..2a8e2b8 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1111,7 +1111,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--relative-date\")) {\n-\t\t\t\trevs->relative_date = 1;\n+\t\t\t\trevs->date_mode = DATE_RELATIVE;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tif (!strcmp(arg, \"--local-zone\")) {\n+\t\t\t\trevs->date_mode = DATE_LOCAL;\n \t\t\t\tcontinue;\n \t\t\t}\n \ndiff --git a/revision.h b/revision.h\nindex 5b41e2d..8f8720a 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -64,7 +64,7 @@ struct rev_info {\n \t/* Format info */\n \tunsigned int\tshown_one:1,\n \t\t\tabbrev_commit:1,\n-\t\t\trelative_date:1;\n+\t\t\tdate_mode:2;\n \n \tconst char **ignore_packed; /* pretend objects in these are unpacked */\n \tint num_ignore_packed;\n-- \n1.5.2.rc0.719.gb3626\n"},{"id":"40378","messageId":"20070425064451.GF5942@spearce.org","threadId":"7824","inReplyTo":"1177482982542-git-send-email-junkio@cox.net","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-04-25T06:44:51Z","receivedAt":"2007-04-25T06:44:51Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> This adds --local-zone option to log family of commands, to\n> display timestamps in user's local timezone.\n> \n> Signed-off-by: Junio C Hamano <junkio@cox.net>\n> ---\n> \n>  * I got tired of looking at +0000 timestamps on commits\n>    imported from CVS at day-job.  Does not seem to break\n>    existing tests, but I am not sure if this is useful.\n\nNot only is it useful, I'd like to see a way to make it my default!\n(By my default here I mean a .gitconfig thing that I can set,\nbut not making it the git out-of-the-box default.)\n\nI don't like looking at timestamps in other people's timezones.\nIf git-log is going to go through the motions of performing unicode\ntranslations for my tty, and indent messages, and convert the epoch\nseconds to a human readable date, it most certainly can be nice and\nput the times into my default frame of reference.  Which is whatever\nmy congresscritters have decided the time is this month...  ;-)\n\n-- \nShawn.\n"},{"id":"40397","messageId":"Pine.LNX.4.64.0704251438000.6954@racer.site","threadId":"7824","inReplyTo":"1177482982542-git-send-email-junkio@cox.net","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-04-25T12:40:11Z","receivedAt":"2007-04-25T12:40:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 24 Apr 2007, Junio C Hamano wrote:\n\n> --- a/revision.c\n> +++ b/revision.c\n> @@ -1111,7 +1111,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n>  \t\t\t\tcontinue;\n>  \t\t\t}\n>  \t\t\tif (!strcmp(arg, \"--relative-date\")) {\n> -\t\t\t\trevs->relative_date = 1;\n> +\t\t\t\trevs->date_mode = DATE_RELATIVE;\n> +\t\t\t\tcontinue;\n> +\t\t\t}\n> +\t\t\tif (!strcmp(arg, \"--local-zone\")) {\n> +\t\t\t\trevs->date_mode = DATE_LOCAL;\n>  \t\t\t\tcontinue;\n>  \t\t\t}\n>  \n\nI think that it will become more convenient at some stage to add \n\"--date=local\", and have a common option parser in date.c.\n\n> diff --git a/revision.h b/revision.h\n> index 5b41e2d..8f8720a 100644\n> --- a/revision.h\n> +++ b/revision.h\n> @@ -64,7 +64,7 @@ struct rev_info {\n>  \t/* Format info */\n>  \tunsigned int\tshown_one:1,\n>  \t\t\tabbrev_commit:1,\n> -\t\t\trelative_date:1;\n> +\t\t\tdate_mode:2;\n\nWhy not go the full nine yards, and make this a full int? It's not like \nrev_info is allocated a million times...\n\nCiao,\nDscho\n"},{"id":"40411","messageId":"alpine.LFD.0.98.0704250800030.9964@woody.linux-foundation.org","threadId":"7824","inReplyTo":"1177482982542-git-send-email-junkio@cox.net","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-04-25T15:03:15Z","receivedAt":"2007-04-25T15:03:15Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 24 Apr 2007, Junio C Hamano wrote:\n> \n>  * I got tired of looking at +0000 timestamps on commits\n>    imported from CVS at day-job.  Does not seem to break\n>    existing tests, but I am not sure if this is useful.\n\nI think it's useful (read: I've occasionally wanted it), but I think we \nshould make the date option syntax be more extensible.\n\nIe, it would be better, I think, to use a\n\n\t--date=local\n\t--date=relative\n\t--date=UTC\n\t...\n\nkind of syntax, than have each date flag be different (\"--relative-date\" \nvs \"--local-zone\"?).\n\n\t\t\tLinus\n"},{"id":"40412","messageId":"alpine.LFD.0.98.0704250805440.9964@woody.linux-foundation.org","threadId":"7824","inReplyTo":"alpine.LFD.0.98.0704250800030.9964@woody.linux-foundation.org","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-04-25T15:22:20Z","receivedAt":"2007-04-25T15:22:20Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 25 Apr 2007, Linus Torvalds wrote:\n> \n> Ie, it would be better, I think, to use a\n> \n> \t--date=local\n> \t--date=relative\n> \t--date=UTC\n> \t...\n> \n> kind of syntax, than have each date flag be different (\"--relative-date\" \n> vs \"--local-zone\"?).\n\nBtw, when you do \"--local-zone\", you should drop the TZ printout too, I \nthink. It doesn't seem to make any sense to give the *wrong* timezone.\n\n\t\t\tLinus\n"},{"id":"40434","messageId":"7vr6q8w7hd.fsf@assigned-by-dhcp.cox.net","threadId":"7824","inReplyTo":"alpine.LFD.0.98.0704250805440.9964@woody.linux-foundation.org","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-25T19:59:26Z","receivedAt":"2007-04-25T19:59:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> On Wed, 25 Apr 2007, Linus Torvalds wrote:\n>> \n>> Ie, it would be better, I think, to use a\n>> \n>> \t--date=local\n>> \t--date=relative\n>> \t--date=UTC\n>> \t...\n>> \n>> kind of syntax, than have each date flag be different (\"--relative-date\" \n>> vs \"--local-zone\"?).\n\nProbably.\n\n> Btw, when you do \"--local-zone\", you should drop the TZ printout too, I \n> think. It doesn't seem to make any sense to give the *wrong* timezone.\n\nI do not think the definition of \"wrong\" is so clear.\n\nI would not disagree that showing the authordate in timezone the\nauthor was not in means --local-zone is showing a wrong zone,\nbut \"show timestamps in _my_ zone\" is what the option is\nspecifically asking for.\n\nOriginally I did it without timezone, but later I found it\namusing to see \"log --since=2007-03-10 --until=2007-03-12\".\n\n\tNote: in TZ=US/Pacific you would see -0700 and -0800\n\tduring the above commit-time range.\n"},{"id":"40438","messageId":"20070425201212.GD30061@steel.home","threadId":"7824","inReplyTo":"alpine.LFD.0.98.0704250805440.9964@woody.linux-foundation.org","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-25T20:12:12Z","receivedAt":"2007-04-25T20:12:12Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Linus Torvalds, Wed, Apr 25, 2007 17:22:20 +0200:\n> \n> Btw, when you do \"--local-zone\", you should drop the TZ printout too, I \n> think. It doesn't seem to make any sense to give the *wrong* timezone.\n> \n\nThe timezone is interesting to see: it is a hint as to _where_ the\ncommit is coming from. Obviously not reliable, it can be amusing.\n"},{"id":"40443","messageId":"7vk5w0w615.fsf@assigned-by-dhcp.cox.net","threadId":"7824","inReplyTo":"20070425201212.GD30061@steel.home","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-25T20:30:46Z","receivedAt":"2007-04-25T20:30:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> Linus Torvalds, Wed, Apr 25, 2007 17:22:20 +0200:\n>> \n>> Btw, when you do \"--local-zone\", you should drop the TZ printout too, I \n>> think. It doesn't seem to make any sense to give the *wrong* timezone.\n>\n> The timezone is interesting to see: it is a hint as to _where_ the\n> commit is coming from. Obviously not reliable, it can be amusing.\n\nUnless you spotted a bug in the patch, with --local-zone, I do\nnot think you would get any such hint from the zone information.\n"},{"id":"40447","messageId":"20070425204147.GE30061@steel.home","threadId":"7824","inReplyTo":"7vk5w0w615.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-25T20:41:47Z","receivedAt":"2007-04-25T20:41:47Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Wed, Apr 25, 2007 22:30:46 +0200:\n> >> \n> >> Btw, when you do \"--local-zone\", you should drop the TZ printout too, I \n> >> think. It doesn't seem to make any sense to give the *wrong* timezone.\n> >\n> > The timezone is interesting to see: it is a hint as to _where_ the\n> > commit is coming from. Obviously not reliable, it can be amusing.\n> \n> Unless you spotted a bug in the patch, with --local-zone, I do\n> not think you would get any such hint from the zone information.\n> \n\nNo, not in your patch. For example, look at the timezone information\nin the Date: and Received: headers of this mail.\n"},{"id":"40454","messageId":"7v8xcgw4jy.fsf@assigned-by-dhcp.cox.net","threadId":"7824","inReplyTo":"20070425204147.GE30061@steel.home","subject":"Re: [PATCH] Add date format --local-zone","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-25T21:02:41Z","receivedAt":"2007-04-25T21:02:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> Junio C Hamano, Wed, Apr 25, 2007 22:30:46 +0200:\n>> >> \n>> >> Btw, when you do \"--local-zone\", you should drop the TZ printout too, I \n>> >> think. It doesn't seem to make any sense to give the *wrong* timezone.\n>> >\n>> > The timezone is interesting to see: it is a hint as to _where_ the\n>> > commit is coming from. Obviously not reliable, it can be amusing.\n>> \n>> Unless you spotted a bug in the patch, with --local-zone, I do\n>> not think you would get any such hint from the zone information.\n>> \n>\n> No, not in your patch. For example, look at the timezone information\n> in the Date: and Received: headers of this mail.\n\nOk, I misunderstood.  I did not realize that you were making a\ncomment that was totally unrelated to the --local-zone option.\n"},{"id":"40486","messageId":"11775633782185-git-send-email-junkio@cox.net","threadId":"7824","inReplyTo":"alpine.LFD.0.98.0704250800030.9964@woody.linux-foundation.org","subject":"[PATCH 1/2] Add --date={local,relative,default}","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-26T04:56:17Z","receivedAt":"2007-04-26T04:56:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This adds --date={local,relative,default} option to log family of commands,\nto allow displaying timestamps in user's local timezone, relative time, or\nthe default format.\n\nExisting --relative-date option is a synonym of --date=relative; we could\nprobably deprecate it in the long run.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n  >>   I think it's useful (read: I've occasionally wanted it), but I think we \n  >>   should make the date option syntax be more extensible.\n  >> \n  >>   Ie, it would be better, I think, to use a\n  >> \n  >> \t  --date=local\n  >> \t  --date=relative\n  >> \t  --date=UTC\n  >> \t  ...\n  >> \n  >>   kind of syntax, than have each date flag be different (\"--relative-date\" \n\n  And I obviously agree.\n\n Documentation/git-rev-list.txt |   14 +++++++++++++-\n builtin-rev-list.c             |    2 +-\n cache.h                        |    2 +-\n commit.c                       |   12 ++++++------\n commit.h                       |    2 +-\n date.c                         |   35 +++++++++++++++++++++++++++++++++--\n log-tree.c                     |    4 ++--\n revision.c                     |   13 ++++++++++++-\n revision.h                     |    4 ++--\n 9 files changed, 71 insertions(+), 17 deletions(-)\n\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\nindex 77e068b..1b12b4f 100644\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -25,6 +25,7 @@ SYNOPSIS\n \t     [ \\--cherry-pick ]\n \t     [ \\--encoding[=<encoding>] ]\n \t     [ \\--(author|committer|grep)=<pattern> ]\n+\t     [ \\--date={local|relative|default} ]\n \t     [ [\\--objects | \\--objects-edge] [ \\--unpacked ] ]\n \t     [ \\--pretty | \\--header ]\n \t     [ \\--bisect ]\n@@ -90,9 +91,20 @@ include::pretty-formats.txt[]\n \n --relative-date::\n \n-\tShow dates relative to the current time, e.g. \"2 hours ago\".\n+\tSynonym for `--date=relative`.\n+\n+--date={relative,local,default}::\n+\n \tOnly takes effect for dates shown in human-readable format, such\n \tas when using \"--pretty\".\n++\n+`--date=relative` shows dates relative to the current time,\n+e.g. \"2 hours ago\".\n++\n+`--date=local` shows timestamps in user's local timezone.\n++\n+`--date=default` shows timestamps in the original timezone\n+(either committer's or author's).\n \n --header::\n \ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex c0329dc..ebf53f5 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -95,7 +95,7 @@ static void show_commit(struct commit *commit)\n \t\tstatic char pretty_header[16384];\n \t\tpretty_print_commit(revs.commit_format, commit, ~0,\n \t\t\t\t    pretty_header, sizeof(pretty_header),\n-\t\t\t\t    revs.abbrev, NULL, NULL, revs.relative_date);\n+\t\t\t\t    revs.abbrev, NULL, NULL, revs.date_mode);\n \t\tprintf(\"%s%c\", pretty_header, hdr_termination);\n \t}\n \tfflush(stdout);\ndiff --git a/cache.h b/cache.h\nindex 38a0cbd..8e76152 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 };\n+enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL };\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 10466c4..f1ba972 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -526,7 +526,7 @@ static int add_rfc2047(char *buf, const char *line, int len,\n }\n \n static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,\n-\t\t\t const char *line, int relative_date,\n+\t\t\t const char *line, enum date_mode dmode,\n \t\t\t const char *encoding)\n {\n \tchar *date;\n@@ -569,7 +569,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,\n \tswitch (fmt) {\n \tcase CMIT_FMT_MEDIUM:\n \t\tret += sprintf(buf + ret, \"Date:   %s\\n\",\n-\t\t\t       show_date(time, tz, relative_date));\n+\t\t\t       show_date(time, tz, dmode));\n \t\tbreak;\n \tcase CMIT_FMT_EMAIL:\n \t\tret += sprintf(buf + ret, \"Date: %s\\n\",\n@@ -577,7 +577,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,\n \t\tbreak;\n \tcase CMIT_FMT_FULLER:\n \t\tret += sprintf(buf + ret, \"%sDate: %s\\n\", what,\n-\t\t\t       show_date(time, tz, relative_date));\n+\t\t\t       show_date(time, tz, dmode));\n \t\tbreak;\n \tdefault:\n \t\t/* notin' */\n@@ -919,7 +919,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,\n \t\t\t\t  char *buf, unsigned long space,\n \t\t\t\t  int abbrev, const char *subject,\n \t\t\t\t  const char *after_subject,\n-\t\t\t\t  int relative_date)\n+\t\t\t\t  enum date_mode dmode)\n {\n \tint hdr = 1, body = 0, seen_title = 0;\n \tunsigned long offset = 0;\n@@ -1023,14 +1023,14 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,\n \t\t\t\toffset += add_user_info(\"Author\", fmt,\n \t\t\t\t\t\t\tbuf + offset,\n \t\t\t\t\t\t\tline + 7,\n-\t\t\t\t\t\t\trelative_date,\n+\t\t\t\t\t\t\tdmode,\n \t\t\t\t\t\t\tencoding);\n \t\t\tif (!memcmp(line, \"committer \", 10) &&\n \t\t\t    (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER))\n \t\t\t\toffset += add_user_info(\"Commit\", fmt,\n \t\t\t\t\t\t\tbuf + offset,\n \t\t\t\t\t\t\tline + 10,\n-\t\t\t\t\t\t\trelative_date,\n+\t\t\t\t\t\t\tdmode,\n \t\t\t\t\t\t\tencoding);\n \t\t\tcontinue;\n \t\t}\ndiff --git a/commit.h b/commit.h\nindex 59de17e..86e8dca 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -61,7 +61,7 @@ enum cmit_fmt {\n };\n \n extern enum cmit_fmt get_commit_format(const char *arg);\n-extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date);\n+extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode);\n \n /** Removes the first commit from a list sorted by date, and adds all\n  * of its parents.\ndiff --git a/date.c b/date.c\nindex 0ceccbe..a9b59a2 100644\n--- a/date.c\n+++ b/date.c\n@@ -55,6 +55,32 @@ static struct tm *time_to_tm(unsigned long time, int tz)\n \treturn gmtime(&t);\n }\n \n+/*\n+ * What value of \"tz\" was in effect back then at \"time\" in the\n+ * local timezone?\n+ */\n+static int local_tzoffset(unsigned long time)\n+{\n+\ttime_t t, t_local;\n+\tstruct tm tm;\n+\tint offset, eastwest;\n+\n+\tt = time;\n+\tlocaltime_r(&t, &tm);\n+\tt_local = my_mktime(&tm);\n+\n+\tif (t_local < t) {\n+\t\teastwest = -1;\n+\t\toffset = t - t_local;\n+\t} else {\n+\t\teastwest = 1;\n+\t\toffset = t_local - t;\n+\t}\n+\toffset /= 60; /* in minutes */\n+\toffset = (offset % 60) + ((offset / 60) * 100);\n+\treturn offset * eastwest;\n+}\n+\n const char *show_date(unsigned long time, int tz, enum date_mode mode)\n {\n \tstruct tm *tm;\n@@ -102,6 +128,9 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \t\t/* Else fall back on absolute format.. */\n \t}\n \n+\tif (mode == DATE_LOCAL)\n+\t\ttz = local_tzoffset(time);\n+\n \ttm = time_to_tm(time, tz);\n \tif (!tm)\n \t\treturn NULL;\n@@ -109,12 +138,14 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \t\tsprintf(timebuf, \"%04d-%02d-%02d\", tm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1, tm->tm_mday);\n \telse\n-\t\tsprintf(timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d %+05d\",\n+\t\tsprintf(timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d\",\n \t\t\t\tweekday_names[tm->tm_wday],\n \t\t\t\tmonth_names[tm->tm_mon],\n \t\t\t\ttm->tm_mday,\n \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n-\t\t\t\ttm->tm_year + 1900, tz);\n+\t\t\t\ttm->tm_year + 1900,\n+\t\t\t\t(mode == DATE_LOCAL) ? 0 : ' ',\n+\t\t\t\ttz);\n \treturn timebuf;\n }\n \ndiff --git a/log-tree.c b/log-tree.c\nindex 300b733..c679324 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -267,7 +267,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\tif (opt->reflog_info) {\n \t\t\tshow_reflog_message(opt->reflog_info,\n \t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n-\t\t\t\t    opt->relative_date);\n+\t\t\t\t    opt->date_mode);\n \t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n \t\t\t\tprintf(\"%s\", sep);\n \t\t\t\treturn;\n@@ -280,7 +280,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t */\n \tlen = pretty_print_commit(opt->commit_format, commit, ~0u, this_header,\n \t\t\t\t  sizeof(this_header), abbrev, subject,\n-\t\t\t\t  extra_headers, opt->relative_date);\n+\t\t\t\t  extra_headers, opt->date_mode);\n \n \tif (opt->add_signoff)\n \t\tlen = append_signoff(this_header, sizeof(this_header), len,\ndiff --git a/revision.c b/revision.c\nindex 49bd292..e60a26c 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1111,7 +1111,18 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--relative-date\")) {\n-\t\t\t\trevs->relative_date = 1;\n+\t\t\t\trevs->date_mode = DATE_RELATIVE;\n+\t\t\t\tcontinue;\n+\t\t\t}\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, \"local\"))\n+\t\t\t\t\trevs->date_mode = DATE_LOCAL;\n+\t\t\t\telse if (!strcmp(arg + 7, \"default\"))\n+\t\t\t\t\trevs->date_mode = DATE_NORMAL;\n+\t\t\t\telse\n+\t\t\t\t\tdie(\"unknown date format %s\", arg);\n \t\t\t\tcontinue;\n \t\t\t}\n \ndiff --git a/revision.h b/revision.h\nindex 5b41e2d..cdf94ad 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -63,8 +63,8 @@ struct rev_info {\n \n \t/* Format info */\n \tunsigned int\tshown_one:1,\n-\t\t\tabbrev_commit:1,\n-\t\t\trelative_date:1;\n+\t\t\tabbrev_commit:1;\n+\tenum date_mode date_mode;\n \n \tconst char **ignore_packed; /* pretend objects in these are unpacked */\n \tint num_ignore_packed;\n-- \n1.5.2.rc0.719.gb3626\n"},{"id":"40502","messageId":"87y7kfzkvq.fsf@morpheus.local","threadId":"7824","inReplyTo":"11775633782185-git-send-email-junkio@cox.net","subject":"Re: [PATCH 1/2] Add --date={local,relative,default}","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-04-26T06:54:01Z","receivedAt":"2007-04-26T06:54:01Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> ++\n> +`--date=relative` shows dates relative to the current time,\n> +e.g. \"2 hours ago\".\n> ++\n> +`--date=local` shows timestamps in user's local timezone.\n> ++\n> +`--date=default` shows timestamps in the original timezone\n> +(either committer's or author's).\n\nWhy is \"default\" called \"default\" and not, say, \"original\"?  What if I\nchanged the default format to \"local\" using local configuration.  What\nwould \"default\" show then?\n\n-- \nDavid Kågedal\n"}]}