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

Re: ambiguous git-log date and timestamp syntax

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 1, 2008, 22:26 UTC
Message-ID
<200803012326.05698.jnareb@gmail.com>
In-Reply-To
<alpine.LFD.1.00.0803011010480.17889@woody.linux-foundation.org>
On Sat, 1 Mar 2008, Linus Torvalds wrote:
Show 22 quoted lines
> On Sat, 1 Mar 2008, Jakub Narebski wrote:
> > > 
> > > From what I can tell it seems that dates can be specified relatively,
> > > e.g. "2 hours ago", or with any ISO 8601 or RFC 2822 date syntax. Is
> > > this correct, and are there any docs on specifying relative dates?
> > 
> > I don't know why git doesn't use getdate_r for this, instead rolling
> > out its own date parsing routines: approxidate*, parse_date. From what
> > I remember it should accept any date "date" (from coreutils) accepts,
> > but it does (from comments) for date to be in "C" locale.
> 
> strptime() and getdate() are totally unusable for any real date parsing 
> where you don't already know the exact format(s) of the string. And 
> neither of them can do any of the useful things that approxidate() does, 
> ie handle strings like "two months ago".
> 
> So yes, we do our own date parsing, where the "exact" format is the Unix 
> epoch timestamp (potentially together with explicit TZ information), but 
> we try to parse a wide variety of user-supplied strings that match any of 
> the standard formats (and do that loosely, so that when emails etc 
> invariably get things wrong and don't actually follow rfc2822 exactly, for 
> example, it still tries to make sense of it).

I wonder how it compares with GNU date (from GNU Corutils) inexact date parsing (and why we couldn't lift the code from GNU date)... I guess that main goal was to parse correctly "mail" dates, first.

BTW. Git has few other such "reimplementing the wheel" things, like strbuf, or ALLOC_GROW, or it's own parseopt. I guess main reasons are to avoid adding yet another dependency, and that existing solutions doesn't fill all git needs.

-- 
Jakub Narebski
Poland
Previous: Linus TorvaldsNext: Johannes Schindelin
Message 4 of 9 in “ambiguous git-log date and timestamp syntax”
  1. Rhodes, KateMar 1, 2008
  2. Jakub NarebskiMar 1, 2008
  3. Linus TorvaldsMar 1, 2008
  4. Jakub NarebskiMar 1, 2008
  5. Johannes SchindelinMar 2, 2008
  6. Jakub NarebskiMar 2, 2008
  7. Johannes SchindelinMar 2, 2008
  8. Florian WeimerMar 2, 2008
  9. Documentation: Remove --{min,max}-age option from git-log(1)Jakub Narebski, Mar 2, 2008

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.