{"thread":{"id":"2577","subject":"Teach \"approxidate\" about weekday syntax","startedAt":"2005-11-17T20:36:30Z","lastAt":"2005-11-20T23:36:13Z","messageCount":26,"participants":["Linus Torvalds","Nicolas Pitre","Johannes Schindelin","Junio C Hamano","H. Peter Anvin","Martin Langhoff","David Roundy","Randy.Dunlap","Andreas Ericsson","Randal L. Schwartz","Matthias Urlichs"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"12140","messageId":"Pine.LNX.4.64.0511171223110.13959@g5.osdl.org","threadId":"2577","inReplyTo":null,"subject":"Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-17T20:36:30Z","receivedAt":"2005-11-17T20:36:30Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nThis allows people to use syntax like \"last thursday\" for the approxidate. \n\n(Or, indeed, more complex \"three thursdays ago\", but I suspect that would \nbe pretty unusual).\n\nNOTE! The parsing is strictly sequential, so if you do\n\n\t\"one day before last thursday\"\n\nit will _not_ do what you think it does. It will take the current time, \nsubtract one day, and then go back to the thursday before that. So to get \nwhat you want, you'd have to write it the other way around:\n\n\t\"last thursday and one day before\"\n\nwhich is insane (it's usually the same as \"last wednesday\" _except_ if \ntoday is Thursday, in which case \"last wednesday\" is yesterday, and \"last \nthursday and one day before\" is eight days ago).\n\nSimilarly,\n\n\t\"last thursday one month ago\"\n\nwill first go back to last thursday, and then go back one month from \nthere, not the other way around.\n\nI doubt anybody would ever use insane dates like that, but I thought I'd \npoint out that the approxidate parsing is not exactly \"standard English\".\n\nSide note 2: if you want to avoid spaces (because of quoting issues), you \ncan use any non-alphanumberic character instead. So\n\n\tgit log --since=2.days.ago\n\nworks without any quotes.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/date.c b/date.c\nindex 73c063b..d2a67cc 100644\n--- a/date.c\n+++ b/date.c\n@@ -34,7 +34,7 @@ static const char *month_names[] = {\n };\n \n static const char *weekday_names[] = {\n-\t\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"\n+\t\"Sundays\", \"Mondays\", \"Tuesdays\", \"Wednesdays\", \"Thursdays\", \"Fridays\", \"Saturdays\"\n };\n \n /*\n@@ -531,6 +531,22 @@ static const char *approxidate_alpha(con\n \t\ttl++;\n \t}\n \n+\tfor (i = 0; i < 7; i++) {\n+\t\tint match = match_string(date, weekday_names[i]);\n+\t\tif (match >= 3) {\n+\t\t\tint diff, n = *num -1;\n+\t\t\t*num = 0;\n+\n+\t\t\tdiff = tm->tm_wday - i;\n+\t\t\tif (diff <= 0)\n+\t\t\t\tn++;\n+\t\t\tdiff += 7*n;\n+\n+\t\t\tupdate_tm(tm, diff * 24 * 60 * 60);\n+\t\t\treturn end;\n+\t\t}\n+\t}\n+\n \tif (match_string(date, \"months\") >= 5) {\n \t\tint n = tm->tm_mon - *num;\n \t\t*num = 0;\n"},{"id":"12143","messageId":"Pine.LNX.4.64.0511171622450.14287@localhost.localdomain","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511171223110.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2005-11-17T21:27:23Z","receivedAt":"2005-11-17T21:27:23Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Thu, 17 Nov 2005, Linus Torvalds wrote:\n\n> NOTE! The parsing is strictly sequential, so if you do\n> \n> \t\"one day before last thursday\"\n> \n> it will _not_ do what you think it does. It will take the current time, \n> subtract one day, and then go back to the thursday before that.\n\nMaybe if you applied the different time units in decreasing size that \nwould do the trick?  e.g. months have precedence over weeks, weeks over \nweekdays, weekdays over days, etc.\n\n\nNicolas\n"},{"id":"12147","messageId":"Pine.LNX.4.63.0511172242390.18285@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511171622450.14287@localhost.localdomain","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-17T21:44:05Z","receivedAt":"2005-11-17T21:44:05Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 17 Nov 2005, Nicolas Pitre wrote:\n\n> On Thu, 17 Nov 2005, Linus Torvalds wrote:\n> \n> > NOTE! The parsing is strictly sequential, so if you do\n> > \n> > \t\"one day before last thursday\"\n> > \n> > it will _not_ do what you think it does. It will take the current time, \n> > subtract one day, and then go back to the thursday before that.\n> \n> Maybe if you applied the different time units in decreasing size that \n> would do the trick?  e.g. months have precedence over weeks, weeks over \n> weekdays, weekdays over days, etc.\n\nOr even better: make it relative until you find an absolute reference. \nI.e. \"one day\" will be 1 * 86400, and if you then parse \"before\", it\nwill get negative, then \"last thursday\" will be the absolute reference.\n\n'f course, \"one day before last thursday in september\" will be a PITA.\n\nCiao,\nDscho\n"},{"id":"12156","messageId":"7v1x1eubpr.fsf@assigned-by-dhcp.cox.net","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511171223110.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-17T22:54:40Z","receivedAt":"2005-11-17T22:54:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> ..., you'd have to write it the other way around:\n>\n> \t\"last thursday and one day before\"\n>\n> which is insane (it's usually the same as \"last wednesday\" _except_ if \n> today is Thursday, in which case \"last wednesday\" is yesterday, and \"last \n> thursday and one day before\" is eight days ago).\n> ...\n> I doubt anybody would ever use insane dates like that, but I thought I'd \n> point out that the approxidate parsing is not exactly \"standard English\".\n\nIt is not English but Gittish, which is fine, but it somehow\nreminds me of the funny way users make themselves understood by\nIF parsers ;-).  I am afraid you started small but now are going\ntowards the same insanity of gnudate (it has insane yacc grammar\nto grok these things), and I suspect we'd better draw a line\nsomewhere.\n\n> Side note 2: if you want to avoid spaces (because of quoting issues), you \n> can use any non-alphanumberic character instead. So\n>\n> \tgit log --since=2.days.ago\n>\n> works without any quotes.\n\nI think this is a useful change.  Thanks.\n"},{"id":"12160","messageId":"437D0FC8.6000906@zytor.com","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511171223110.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-11-17T23:18:32Z","receivedAt":"2005-11-17T23:18:32Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Linus Torvalds wrote:\n> This allows people to use syntax like \"last thursday\" for the approxidate. \n> \n> (Or, indeed, more complex \"three thursdays ago\", but I suspect that would \n> be pretty unusual).\n> \n> NOTE! The parsing is strictly sequential, so if you do\n> \n> \t\"one day before last thursday\"\n> \n> it will _not_ do what you think it does. It will take the current time, \n> subtract one day, and then go back to the thursday before that. So to get \n> what you want, you'd have to write it the other way around:\n> \n> \t\"last thursday and one day before\"\n> \n> which is insane (it's usually the same as \"last wednesday\" _except_ if \n> today is Thursday, in which case \"last wednesday\" is yesterday, and \"last \n> thursday and one day before\" is eight days ago).\n> \n> Similarly,\n> \n> \t\"last thursday one month ago\"\n> \n> will first go back to last thursday, and then go back one month from \n> there, not the other way around.\n> \n> I doubt anybody would ever use insane dates like that, but I thought I'd \n> point out that the approxidate parsing is not exactly \"standard English\".\n> \n\nI believe English would always parse from right to left, it might be the \nright thing to do...\n\n\t-hpa\n"},{"id":"12159","messageId":"Pine.LNX.4.64.0511171505080.13959@g5.osdl.org","threadId":"2577","inReplyTo":"7v1x1eubpr.fsf@assigned-by-dhcp.cox.net","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-17T23:18:53Z","receivedAt":"2005-11-17T23:18:53Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 17 Nov 2005, Junio C Hamano wrote:\n>\n> It is not English but Gittish, which is fine, but it somehow\n> reminds me of the funny way users make themselves understood by\n> IF parsers ;-).  I am afraid you started small but now are going\n> towards the same insanity of gnudate (it has insane yacc grammar\n> to grok these things), and I suspect we'd better draw a line\n> somewhere.\n\nI think I'm done.\n\nThe multi-week \"3 sundays ago\" part came for free, but the \"last sunday\" \nwas actually something I liked.\n\nSeriously, I can't imagine what else we'd want. It parses exact dates \n(thanks to the old date-parsing code), and it now parses all the normal \n\"lazy dates\" I can think of.\n\nThe fact that you can combine \"last saturday\" with \"three days ago\" is \nreally not a feature as much as a result of the algorithm being so simple \nthat it just doesn't care, and the combination just happens to work.\n\nMy examples were a bit silly as a result. In real life, you'd probably \nnever use any combinations, but simply use\n\n\t\"December 5th\"\n\t\"last sunday\"\n\t\"yesterday\"\n\t\"two days ago\"\n\t\"12 hours ago\"\n\nand the fact that then some (but definitely not all) combinations of the \nabove all work is really just an accident and not something that people \nshould necessarily even depend on.\n\n> > Side note 2: if you want to avoid spaces (because of quoting issues), you \n> > can use any non-alphanumberic character instead. So\n> >\n> > \tgit log --since=2.days.ago\n> >\n> > works without any quotes.\n> \n> I think this is a useful change.  Thanks.\n\nThat's actually not a new change, the approxidate thing always worked that \nway, but I thought I'd point it out.\n\n\t\tLinus\n"},{"id":"12162","messageId":"Pine.LNX.4.64.0511171520390.13959@g5.osdl.org","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511171505080.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-17T23:23:00Z","receivedAt":"2005-11-17T23:23:00Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 17 Nov 2005, Linus Torvalds wrote:\n>\n> I think I'm done.\n\nThe only thing I might want to do is add some support for time-of-day to \nthe thing. Notably \"noon\" and \"midnight\".\n\n\t\tLinus\n"},{"id":"12165","messageId":"Pine.LNX.4.64.0511171523170.13959@g5.osdl.org","threadId":"2577","inReplyTo":"437D0FC8.6000906@zytor.com","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-17T23:30:05Z","receivedAt":"2005-11-17T23:30:05Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 17 Nov 2005, H. Peter Anvin wrote:\n> \n> I believe English would always parse from right to left, it might be the right\n> thing to do...\n\nI'll try if that makes any difference. It would have some other advantages \n(ie it would make it easy to actually differentiate between \"ago\" and \n\"from now\").\n\n\t\tLinus\n"},{"id":"12166","messageId":"Pine.LNX.4.63.0511180030260.18775@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511171505080.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-17T23:32:02Z","receivedAt":"2005-11-17T23:32:02Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 17 Nov 2005, Linus Torvalds wrote:\n\n> Seriously, I can't imagine what else we'd want.\n\nAn error when there's a chance the result is unexpected?\n\nCiao,\nDscho\n"},{"id":"12173","messageId":"46a038f90511171740x756b0336ib8b8937ee3a2af03@mail.gmail.com","threadId":"2577","inReplyTo":"Pine.LNX.4.63.0511180030260.18775@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-11-18T01:40:57Z","receivedAt":"2005-11-18T01:40:57Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 11/18/05, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> On Thu, 17 Nov 2005, Linus Torvalds wrote:\n> > Seriously, I can't imagine what else we'd want.\n> An error when there's a chance the result is unexpected?\n\nThat'd be even harder to define -- I'd rather have it spit out what it\ninterpreted so that porcelains can display it to the user. The user\ncan tell at a glance if the parser is off -- for it will be off by a\nmile.\n\n\nm\n"},{"id":"12174","messageId":"Pine.LNX.4.64.0511171828380.13959@g5.osdl.org","threadId":"2577","inReplyTo":"46a038f90511171740x756b0336ib8b8937ee3a2af03@mail.gmail.com","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-18T02:38:23Z","receivedAt":"2005-11-18T02:38:23Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 18 Nov 2005, Martin Langhoff wrote:\n> \n> That'd be even harder to define -- I'd rather have it spit out what it\n> interpreted so that porcelains can display it to the user. The user\n> can tell at a glance if the parser is off -- for it will be off by a\n> mile.\n\nWell, quite frankly, almost always it's pretty damn obvious.\n\nWe could make it less so: the most common mistake when it doesn't parse \nsanely is that it doesn't parse anything at all, but it saw a number \nsomewhere, and thought it was a day of the month.\n\nFor example, \"last janurary\" will silently parse to just \"1\" (miss-spelled \n\"january\"), which will be interpreted as the \"first of this month\".\n\nAnd we could make _that_ be an error. If you want the first of this month, \nyou'd have to spell out the month, ie write \"Nov 1\" instead of just \"1\".\n\nApart from that parsign error, pretty much everything else will tend to \nparse correctly or just give \"now\" (which is pretty obvious when you ask \nfor a log \"since now\", and get an empty answer back).\n\nBut quite frankly, I don't think the approximate date-parsing is serious \nenough to even worry about these kinds of things. I actually use it, but I \ndon't think anybody _depends_ on it. It's useful to do\n\n\tgitk --since=last.week\n\njust as a way to speed up the startup (if you're just interested in the \ntop of the tree, the kernel history is so big that it's just pointless to \ndo a full gitk, and doing the \"since last week\" is a quick way to just \nlimit the history enough that it makes the graph cleaner).\n\nAnd if you get that wrong, who cares? It's not a big deal. The approxidate \nparsing is one of those \"hey, that's nice\" features, but it's definitely \nnot important.\n\n\t\tLinus\n"},{"id":"12176","messageId":"Pine.LNX.4.63.0511180350430.6359@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2577","inReplyTo":"46a038f90511171740x756b0336ib8b8937ee3a2af03@mail.gmail.com","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-18T02:53:14Z","receivedAt":"2005-11-18T02:53:14Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 18 Nov 2005, Martin Langhoff wrote:\n\n> On 11/18/05, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > On Thu, 17 Nov 2005, Linus Torvalds wrote:\n> > > Seriously, I can't imagine what else we'd want.\n> > An error when there's a chance the result is unexpected?\n> \n> That'd be even harder to define -- I'd rather have it spit out what it\n> interpreted so that porcelains can display it to the user. The user\n> can tell at a glance if the parser is off -- for it will be off by a\n> mile.\n\nYes, it may be off by a mile. But if there exists a feature to specify a \ndate that comfortably, people don't RTFM, but use it.\n\nNow comes the rub: if nothing is displayed, they take it that everything \nwas fine. *If* something was displayed, one knew that the code parsed \nyesterday when last year was meant. But *if not*, nobody knows.\n\nThis is dangerous. It is wrong, but does not say so.\n\nHth,\nDscho\n"},{"id":"12218","messageId":"20051118121210.GA19714@abridgegame.org","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511171520390.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"David Roundy","fromEmail":"droundy@abridgegame.org","sentAt":"2005-11-18T12:12:19Z","receivedAt":"2005-11-18T12:12:19Z","isPatch":false,"sender":{"key":"droundy@abridgegame.org","avatar":"https://gravatar.com/avatar/e8bcfd76f63303732bdfcdba6fc8ac6ccdff8f5a224a25ffaca24bd8a4c4571f?d=mp&s=160"},"body":"On Thu, Nov 17, 2005 at 03:23:00PM -0800, Linus Torvalds wrote:\n> On Thu, 17 Nov 2005, Linus Torvalds wrote:\n> >\n> > I think I'm done.\n> \n> The only thing I might want to do is add some support for time-of-day to \n> the thing. Notably \"noon\" and \"midnight\".\n\nDon't forget \"high noon\"!  (and perhaps \"tea time\"?)  :)\n-- \nDavid Roundy\nhttp://www.darcs.net\n"},{"id":"12220","messageId":"Pine.LNX.4.63.0511181419340.28109@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2577","inReplyTo":"20051118121210.GA19714@abridgegame.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-18T13:20:10Z","receivedAt":"2005-11-18T13:20:10Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 18 Nov 2005, David Roundy wrote:\n\n> Don't forget \"high noon\"!  (and perhaps \"tea time\"?)  :)\n\nHow about \"dooms day\"? I would like to do this:\n\n\tgit-whatchanged -p --until=\"dooms day\"\n\nHmm?\n\nCiao,\nDscho\n"},{"id":"12226","messageId":"Pine.LNX.4.58.0511180806550.25159@shark.he.net","threadId":"2577","inReplyTo":"Pine.LNX.4.63.0511181419340.28109@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Randy.Dunlap","fromEmail":"rdunlap@xenotime.net","sentAt":"2005-11-18T16:08:06Z","receivedAt":"2005-11-18T16:08:06Z","isPatch":false,"sender":{"key":"rdunlap@xenotime.net","avatar":null},"body":"On Fri, 18 Nov 2005, Johannes Schindelin wrote:\n\n> On Fri, 18 Nov 2005, David Roundy wrote:\n>\n> > Don't forget \"high noon\"!  (and perhaps \"tea time\"?)  :)\n>\n> How about \"dooms day\"? I would like to do this:\n>\n> \tgit-whatchanged -p --until=\"dooms day\"\n>\n> Hmm?\n\nSure, and throw in \"ides\" (15th afaik) and moon phases\nwhile you are at it.\n\n-- \n~Randy  [who would just use ISO standard date format]\n"},{"id":"12231","messageId":"Pine.LNX.4.64.0511180842480.13959@g5.osdl.org","threadId":"2577","inReplyTo":"20051118121210.GA19714@abridgegame.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-18T16:56:40Z","receivedAt":"2005-11-18T16:56:40Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 18 Nov 2005, David Roundy wrote:\n> \n> Don't forget \"high noon\"!  (and perhaps \"tea time\"?)  :)\n\nDone.\n\n    [torvalds@g5 git]$ ./test-date \"now\" \"midnight\" \"high noon\" \"tea-time\"\n    now -> bad -> Wed Dec 31 16:00:00 1969\n    now -> Fri Nov 18 08:50:54 2005\n\n    midnight -> bad -> Wed Dec 31 16:00:00 1969\n    midnight -> Fri Nov 18 00:00:00 2005\n\n    high noon -> bad -> Wed Dec 31 16:00:00 1969\n    high noon -> Thu Nov 17 12:00:00 2005\n\n    tea-time -> bad -> Wed Dec 31 16:00:00 1969\n    tea-time -> Thu Nov 17 17:00:00 2005\n\nThanks for pointing out tea-time.\n\nThis is also written to easily extended to allow people to add their own \nimportant dates like Christmas and their own birthdays.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/date.c b/date.c\nindex d2a67cc..3e11500 100644\n--- a/date.c\n+++ b/date.c\n@@ -468,12 +468,52 @@ static void update_tm(struct tm *tm, uns\n \tlocaltime_r(&n, tm);\n }\n \n+static void date_yesterday(struct tm *tm, int *num)\n+{\n+\tupdate_tm(tm, 24*60*60);\n+}\n+\n+static void date_time(struct tm *tm, int hour)\n+{\n+\tif (tm->tm_hour < hour)\n+\t\tdate_yesterday(tm, NULL);\n+\ttm->tm_hour = hour;\n+\ttm->tm_min = 0;\n+\ttm->tm_sec = 0;\n+}\n+\n+static void date_midnight(struct tm *tm, int *num)\n+{\n+\tdate_time(tm, 0);\n+}\n+\n+static void date_noon(struct tm *tm, int *num)\n+{\n+\tdate_time(tm, 12);\n+}\n+\n+static void date_tea(struct tm *tm, int *num)\n+{\n+\tdate_time(tm, 17);\n+}\n+\n+static const struct special {\n+\tconst char *name;\n+\tvoid (*fn)(struct tm *, int *);\n+} special[] = {\n+\t{ \"yesterday\", date_yesterday },\n+\t{ \"noon\", date_noon },\n+\t{ \"midnight\", date_midnight },\n+\t{ \"tea\", date_tea },\n+\t{ NULL }\n+};\n+\n static const char *number_name[] = {\n \t\"zero\", \"one\", \"two\", \"three\", \"four\",\n \t\"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\",\n };\n \n-static struct typelen {\n+static const struct typelen {\n \tconst char *type;\n \tint length;\n } typelen[] = {\n@@ -487,7 +527,8 @@ static struct typelen {\n \n static const char *approxidate_alpha(const char *date, struct tm *tm, int *num)\n {\n-\tstruct typelen *tl;\n+\tconst struct typelen *tl;\n+\tconst struct special *s;\n \tconst char *end = date;\n \tint n = 1, i;\n \n@@ -502,9 +543,12 @@ static const char *approxidate_alpha(con\n \t\t}\n \t}\n \n-\tif (match_string(date, \"yesterday\") > 8) {\n-\t\tupdate_tm(tm, 24*60*60);\n-\t\treturn end;\n+\tfor (s = special; s->name; s++) {\n+\t\tint len = strlen(s->name);\n+\t\tif (match_string(date, s->name) == len) {\n+\t\t\ts->fn(tm, num);\n+\t\t\treturn end;\n+\t\t}\n \t}\n \n \tif (!*num) {\n"},{"id":"12282","messageId":"Pine.LNX.4.64.0511180857170.13959@g5.osdl.org","threadId":"2577","inReplyTo":"Pine.LNX.4.58.0511180806550.25159@shark.he.net","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-18T17:00:38Z","receivedAt":"2005-11-18T17:00:38Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 18 Nov 2005, Randy.Dunlap wrote:\n>\n> ~Randy  [who would just use ISO standard date format]\n\nThat actually _does_ work, and has done so since the beginning:\n\n   [torvalds@g5 git]$ ./test-date \"2005-11-02 14:45:00\"\n   2005-11-02 14:45:00 -> 1130971500 -0800 -> Wed Nov  2 14:45:00 2005\n   2005-11-02 14:45:00 -> Wed Nov  2 14:45:00 2005\n\nie both the exact and the fuzzy date parsing will happily accept ISO \nstandard date format and exact times.\n\nBut when you want to know what happened since high tea yesterday, the \nfuzzy format is unbeatable.\n\n\t\t\tLinus\n"},{"id":"12278","messageId":"437E0ECC.8000503@op5.se","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511180842480.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-18T17:26:36Z","receivedAt":"2005-11-18T17:26:36Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Linus Torvalds wrote:\n> \n> On Fri, 18 Nov 2005, David Roundy wrote:\n> \n>>Don't forget \"high noon\"!  (and perhaps \"tea time\"?)  :)\n> \n> \n> Done.\n> \n\nWhat about Discordian dates? You seem to be having so much fun and I'd \nhate to spoil it for you. :)\n\nIt should be easier than Gregorian ones too.\n\n5 months with 73 days each; Chaos, Discord, Confusion, Bureaucracy, The \nAftermath\n5 days: Sweetmorn, Boomtime, Pungenday, Prickle-Prickle, Setting Orange\n\nFebruary 29 is \"St. Tibs day\".\n\nFor years, just tack on 1166 and you're good to go.\n\nIt'd be just lovely to be able to say\n\tgit whatchanged --since=chaos\n\nIncidentally, git was first released in \"Discord\" which seems somehow \nappropriate. :)\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"12232","messageId":"Pine.LNX.4.64.0511180931390.13959@g5.osdl.org","threadId":"2577","inReplyTo":"437E0ECC.8000503@op5.se","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-18T17:33:16Z","receivedAt":"2005-11-18T17:33:16Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 18 Nov 2005, Andreas Ericsson wrote:\n> \n> 5 months with 73 days each; Chaos, Discord, Confusion, Bureaucracy, The\n> Aftermath\n> 5 days: Sweetmorn, Boomtime, Pungenday, Prickle-Prickle, Setting Orange\n> \n> February 29 is \"St. Tibs day\".\n\nI'm sorry, but having \"git log --since=confusion\" would just be \nirresponsible.\n\n\t\tLinus\n"},{"id":"12391","messageId":"pan.2005.11.18.18.07.37.819505@smurf.noris.de","threadId":"2577","inReplyTo":"Pine.LNX.4.58.0511180806550.25159@shark.he.net","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2005-11-18T18:07:39Z","receivedAt":"2005-11-18T18:07:39Z","isPatch":false,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Randy.Dunlap wrote:\n\n> ~Randy  [who would just use ISO standard date format]\n\nYou can't just use non-confusing dates. \nPeople used to confusion would be confused.\n\nSpeaking of which ..:\n\nLinus Torvalds wrote:\n>> 5 months with 73 days each; Chaos, Discord, Confusion, Bureaucracy, The\n>>  Aftermath\n> I'm sorry, but having \"git log --since=confusion\" would just be\n> irresponsible.\n> \nPossibly, but on the other hand there'd be a lot more truth in these than\nin our current month names. (November hasn't been the ninth month for\n*some* time now...)\n\n-- \nMatthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de\nDisclaimer: The quote was selected randomly. Really. | http://smurf.noris.de\n - -\nWhile there's life, there's hope.\n\t\t-- Publius Terentius Afer (Terence)\n"},{"id":"12274","messageId":"437E18B8.8040909@zytor.com","threadId":"2577","inReplyTo":"Pine.LNX.4.63.0511181419340.28109@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-11-18T18:08:56Z","receivedAt":"2005-11-18T18:08:56Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Fri, 18 Nov 2005, David Roundy wrote:\n> \n> \n>>Don't forget \"high noon\"!  (and perhaps \"tea time\"?)  :)\n> \n> \n> How about \"dooms day\"? I would like to do this:\n> \n> \tgit-whatchanged -p --until=\"dooms day\"\n> \n\nDomesday was some time in August 1086, right?\n\n\t-hpa\n"},{"id":"12295","messageId":"7vzmo1ecbf.fsf@assigned-by-dhcp.cox.net","threadId":"2577","inReplyTo":"Pine.LNX.4.64.0511180857170.13959@g5.osdl.org","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-19T00:00:36Z","receivedAt":"2005-11-19T00:00:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> On Fri, 18 Nov 2005, Randy.Dunlap wrote:\n>>\n>> ~Randy  [who would just use ISO standard date format]\n>\n> That actually _does_ work, and has done so since the beginning:\n>\n>    [torvalds@g5 git]$ ./test-date \"2005-11-02 14:45:00\"\n\nDoesn't ISO spell that as \"2005-11-02T14:45:00\"?\n"},{"id":"12294","messageId":"437E6CAB.8060200@op5.se","threadId":"2577","inReplyTo":"7vzmo1ecbf.fsf@assigned-by-dhcp.cox.net","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-19T00:07:07Z","receivedAt":"2005-11-19T00:07:07Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Linus Torvalds <torvalds@osdl.org> writes:\n> \n> \n>>On Fri, 18 Nov 2005, Randy.Dunlap wrote:\n>>\n>>>~Randy  [who would just use ISO standard date format]\n>>\n>>That actually _does_ work, and has done so since the beginning:\n>>\n>>   [torvalds@g5 git]$ ./test-date \"2005-11-02 14:45:00\"\n> \n> \n> Doesn't ISO spell that as \"2005-11-02T14:45:00\"?\n> \n\nnox!exon:~$ date --iso-8601=seconds\n2005-11-19T01:04:56+0100\n\nNo human will spell it with T though.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"12297","messageId":"864q69bhvz.fsf@blue.stonehenge.com","threadId":"2577","inReplyTo":"437E6CAB.8060200@op5.se","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-11-19T00:28:32Z","receivedAt":"2005-11-19T00:28:32Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Andreas\" == Andreas Ericsson <ae@op5.se> writes:\n\n>>> [torvalds@g5 git]$ ./test-date \"2005-11-02 14:45:00\"\n>> Doesn't ISO spell that as \"2005-11-02T14:45:00\"?\n>> \n\nAndreas> nox!exon:~$ date --iso-8601=seconds\nAndreas> 2005-11-19T01:04:56+0100\n\nAndreas> No human will spell it with T though.\n\nBut they might be getting it out of another tool like that.\n\nAnd, let me apologize for derailing Linus for a week.  Sorry.  :)\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"12301","messageId":"Pine.LNX.4.64.0511181643190.13959@g5.osdl.org","threadId":"2577","inReplyTo":"437E6CAB.8060200@op5.se","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-19T00:48:53Z","receivedAt":"2005-11-19T00:48:53Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 19 Nov 2005, Andreas Ericsson wrote:\n> \n> nox!exon:~$ date --iso-8601=seconds\n> 2005-11-19T01:04:56+0100\n> \n> No human will spell it with T though.\n\nGit doesn't care.\n\n\t./test-date 2005-11-19T01:04:56+0100\n\nresults in\n\n\t2005-11-19T01:04:56+0100 -> 1132358696 +0100 -> Fri Nov 18 16:04:56 2005\n\nwhich should be correct: I'm in PST, test-date shows the \"git time\" \n(seconds since the epoch plus TZ) and then the local time in \nhuman-readable ascii.\n\nThe \"T\" to the git date parser is just a superfluous character that just \nhappens to be a perfectly valid way to separate out the numbers ;)\n\n\t\tLinus\n"},{"id":"12400","messageId":"Pine.LNX.4.63.0511210034370.24681@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2577","inReplyTo":"pan.2005.11.18.18.07.37.819505@smurf.noris.de","subject":"Re: Teach \"approxidate\" about weekday syntax","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-20T23:36:13Z","receivedAt":"2005-11-20T23:36:13Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 18 Nov 2005, Matthias Urlichs wrote:\n\n> Linus Torvalds wrote:\n> > I'm sorry, but having \"git log --since=confusion\" would just be\n> > irresponsible.\n> > \n> Possibly, but on the other hand there'd be a lot more truth in these than\n> in our current month names. (November hasn't been the ninth month for\n> *some* time now...)\n\nWell, I know a girl who gave birth to her child in November. And I guess \nshe's not the only one.\n\nHth,\nDscho\n"}]}