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

Re: Trying to use AUTHOR_DATE

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 30, 2005, 20:32 UTC
Message-ID
<Pine.LNX.4.58.0504301322130.2296@ppc970.osdl.org>
In-Reply-To
<87r7gs87a9.fsf@windlord.stanford.edu>
On Sat, 30 Apr 2005, Russ Allbery wrote:
> 
> You really cannot get portable behavior in this area without something
> akin to Autoconf probes, unfortunately. 

Ok, since this only really matters for AUTHOR_DATE, which we pass in as a random string anyway, and which comes from various mail programs which may or may not follow all RFC's, I just rewrote it to give "almost correct results" for "pretty much any crap you throw at it".

As a test-bed, a "test-date" program that parses a date and then prints it out in git format _and_ in the local timezone format, here's a few examples:

	./test-date "$(date)" "April 4th, 1992 at 13:45" "13:04:09 +0100 2004 Yesterday, Friday 13th, December"
results in
	Sat Apr 30 13:26:52 PDT 2005 -> 1114892812 -0700 -> Sat Apr 30 13:26:52 2005
	April 4th, 1992 at 13:45 -> 702395100 +0000 -> Sat Apr  4 05:45:00 1992
	13:04:09 +0100 2004 Yesterday, Friday 13th, December -> 1102939449 +0100 -> Mon Dec 13 04:04:09 2004
which is just because it really doesn't check a hell of a lot.
For example, if you say
	"I caught 14 fishes in December 1998"
test-date will happily parse this as
	Sun Dec 13 16:00:00 1998
(That's "0:00:00 Dec 14th, 1998 UTC" shown in the local timezone ;). Or:
	./test-date  "12:15 4/17/2009"
	12:15 4/17/2009 -> 1239970500 +0000 -> Fri Apr 17 05:15:00 2009

ie it just greedily tries to make _some_ sense of the random strings you throw at it.

It doesn't even try getting timezones right - it doesn't know about summertime or anything. Besides, I probably used the wrong timezone info anyway.

I'll probably tweak it a bit more (make "no timezone means local timezone", for example, rather than UTC like it is now).

		Linus
Previous: Russ AllberyNext: Juliusz Chroboczek
Message 9 of 31 in “RE: Trying to use AUTHOR_DATE”
  1. Luck, TonyApr 30, 2005
  2. H. Peter AnvinApr 30, 2005
  3. Linus TorvaldsApr 30, 2005
  4. Linus TorvaldsApr 30, 2005
  5. Russ AllberyApr 30, 2005
  6. David WoodhouseApr 30, 2005
  7. Edgar ToernigApr 30, 2005
  8. Russ AllberyApr 30, 2005
  9. Linus TorvaldsApr 30, 2005
  10. Juliusz ChroboczekApr 30, 2005
  11. Edgar ToernigApr 30, 2005
  12. Linus TorvaldsApr 30, 2005
  13. Linus TorvaldsMay 1, 2005
  14. Randy.DunlapMay 1, 2005
  15. Edgar ToernigMay 1, 2005
  16. Junio C HamanoApr 30, 2005
  17. Edgar ToernigApr 30, 2005
  18. David WoodhouseApr 30, 2005
  19. Kay SieversApr 30, 2005
  20. David WoodhouseApr 30, 2005
  21. Edgar ToernigApr 30, 2005
  22. David WoodhouseApr 30, 2005
  23. Edgar ToernigApr 30, 2005
  24. Krzysztof HalasaMay 2, 2005
  25. H. Peter AnvinMay 2, 2005
  26. Krzysztof HalasaMay 2, 2005
  27. H. Peter AnvinMay 2, 2005
  28. Krzysztof HalasaMay 3, 2005
  29. H. Peter AnvinMay 3, 2005
  30. H. Peter AnvinApr 30, 2005
  31. Edgar ToernigApr 30, 2005

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.