Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: sverre@rabbelier.nl
Cc: Brandon Casey <casey@nrlssc.navy.mil>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Date parsing
Date: Tue, 10 Jun 2008 09:55:30 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0806100942500.3101@woody.linux-foundation.org> (raw)
In-Reply-To: <bd6139dc0806100831y7a00a0f4sbc8dee9df7a8c16a@mail.gmail.com>



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").

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 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.

			Linus

  reply	other threads:[~2008-06-10 16:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 14:58 Date parsing Sverre Rabbelier
2008-06-10 15:07 ` Johannes Sixt
2008-06-10 15:27   ` Sverre Rabbelier
2008-06-10 15:10 ` Brandon Casey
2008-06-10 15:31   ` Sverre Rabbelier
2008-06-10 16:55     ` Linus Torvalds [this message]
2008-06-10 17:51       ` Sverre Rabbelier
2008-06-21 21:52       ` Stephan Beyer
2008-06-21 22:28         ` Linus Torvalds
2008-06-21 22:37           ` Linus Torvalds
2008-06-21 22:40           ` Stephan Beyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.10.0806100942500.3101@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=casey@nrlssc.navy.mil \
    --cc=git@vger.kernel.org \
    --cc=sverre@rabbelier.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox