git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Improve on 'approxidate'

From
Jeff King <peff@peff.net>
Date
Aug 30, 2009, 22:35 UTC
Message-ID
<20090830223558.GA29807@coredump.intra.peff.net>
In-Reply-To
<alpine.LFD.2.01.0908221438450.3158@localhost.localdomain>
On Sat, Aug 22, 2009 at 03:10:07PM -0700, Linus Torvalds wrote:
Show 11 quoted lines
>  unsigned long approxidate(const char *date)
>  {
>  	int number = 0;
> @@ -881,21 +911,24 @@ unsigned long approxidate(const char *date)
>  	time_sec = tv.tv_sec;
>  	localtime_r(&time_sec, &tm);
>  	now = tm;
> +
> +	tm.tm_year = -1;
> +	tm.tm_mon = -1;
> +	tm.tm_mday = -1;

This breaks relative dates like "3.months.ago", because approxidate_alpha needs to see the "current" date in tm (and now it sees -1, subtracts from it, and assumes we are just crossing a year boundary because of the negative). 3.years.ago is also broken, but I don't think 3.days.ago is.

Probably we just need to pass "now" to approxidate_alpha, and it needs to call update_tm under the case for "months" and "years" (and I haven't quite figured out why those are not part of the "tl" list). Unfortunately, I'm out of time to look at it more right now, but I'll take a look tonight or tomorrow if you don't beat me to it.

-Peff
Previous: Nicolas PitreNext: Jeff King
Message 4 of 6 in “Improve on 'approxidate'”
  1. Linus TorvaldsAug 22, 2009
  2. Further 'approxidate' improvementsLinus Torvalds, Aug 23, 2009
  3. Nicolas PitreAug 23, 2009
  4. Jeff KingAug 30, 2009
  5. Jeff KingAug 31, 2009
  6. Linus TorvaldsSep 1, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.