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

Re: Date parsing

From
SRSverre Rabbelier <alturin@gmail.com>
Date
Jun 10, 2008, 17:51 UTC
Message-ID
<bd6139dc0806101051t5af7d14an57970f305b09173b@mail.gmail.com>
In-Reply-To
<alpine.LFD.1.10.0806100942500.3101@woody.linux-foundation.org>

On Tue, Jun 10, 2008 at 6:55 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:

Show 18 quoted lines
> On Tue, 10 Jun 2008, Sverre Rabbelier wrote:
>> On Tue, Jun 10, 2008 at 5:10 PM, Brandon Casey <casey@nrlssc.navy.mil> wrote:
>> > Take a look at match_multi_number in date.c
>> > European ordering is preferred when the separator is '.'
>>
>> Ok, then I'll use . in the future, that's nice :).
>
> Well, there are safer ways to give the date.
>
> If you do it in strict rfc822 format, you'll never have any confusion
> what-so-ever. The "approxidate()" thing tries to parse any random input,
> but it *is* meant to be excessively liberal.
>
> IOW, you can literally say "at tea-time two weeks ago" and get a date, and
> it will even work. But you can also say "my 3rd child was born in
> December", and it will also give you a date. The date will not make
> _sense_, but it will give you one (it will decide that what you meant
> is "Dec 3rd").

Ok, so it'll eat anything it can make a date of, that makes sense I guess, considering what you refer to below.

Show 9 quoted lines
> So if you want to be precise and safe, you should be precise. I'd
> personally suggest using yyyy-mm-dd, which is the ISO date format,
> although if that fails approxidate will still try the admittedly
> crazy yyyy-dd-mm.
>
> And always set the timezone explicitly if you really care. Again, we try
> out best if you don't explicitly say which timezone to use, but if you
> don't want any guessing - even _informed_ guessing - you really should
> state things explicitly.

I overlooked the fact that in Januari there is no DST, so that my local timezone would indeed be +1, so it handled it as desired.

Show 14 quoted lines
>> I think that it should bail out when it encounters "20-01-2008"
>> instead of automagically going for european notation. Even more
>> helpfull would be to inform the user that "20.01.2008" is the proper
>> notation.
>
> See above. git approxidate() tries the exact reverse: it's extremely
> willing to turn absolutely any line noise into a date.
>
> Which is really nice when you do
>
>        git log @{last.week}..
>
> but if you actually want to state an exact date it really means that the
> onus is on _you_ to be exact, and use a well-defined standard format.

Thank you, this explained why it works the way it does very well. I'll go with ISO notation in the future :).

-- 
Cheers,

Sverre Rabbelier
Previous: Linus TorvaldsNext: Stephan Beyer
Message 7 of 11 in “Date parsing”
  1. Sverre RabbelierJun 10, 2008
  2. Johannes SixtJun 10, 2008
  3. Sverre RabbelierJun 10, 2008
  4. Brandon CaseyJun 10, 2008
  5. Sverre RabbelierJun 10, 2008
  6. Linus TorvaldsJun 10, 2008
  7. Sverre RabbelierJun 10, 2008
  8. Stephan BeyerJun 21, 2008
  9. Linus TorvaldsJun 21, 2008
  10. Linus TorvaldsJun 21, 2008
  11. Stephan BeyerJun 21, 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.