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

Re: Trying to use AUTHOR_DATE

From
David Woodhouse <dwmw2@infradead.org>
Date
Apr 30, 2005, 08:02 UTC
Message-ID
<1114848175.24014.35.camel@localhost.localdomain>
In-Reply-To
<87zmvganq9.fsf@windlord.stanford.edu>
On Fri, 2005-04-29 at 21:32 -0700, Russ Allbery wrote:
Show 8 quoted lines
> Linus Torvalds <torvalds@osdl.org> writes:
> > It also seems to do so in a particularly stupid way, and David
> > Woodhouses suggestion of just using mktime() on Jan 1st, 1970, seems to
> > be much simpler than what curl does.
> 
> Because of daylight savings time, this doesn't actually work.  I know from
> personal experience; this is the tactic that I took at first when writing
> INN's date parser and was educated by test failures.

Eww. The time functions we have to play with _really_ suck, don't they? How about this...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
commit-tree.c: needs update
Index: commit-tree.c
===================================================================
--- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/commit-tree.c  (mode:100644 sha1:23de13361944ad7ba7c5320cf7cdd04e81842c60)
+++ uncommitted/commit-tree.c  (mode:100644)
@@ -213,10 +213,18 @@
 	if (*(skipfws(p + 5)))
 		return;
 
-	then = mktime(&tm); /* mktime appears to ignore the GMT offset, stupidly */
+	tm.tm_gmtoff = 0;
+	tm.tm_isdst = -1;
+
+	then = mktime(&tm);
 	if (then == -1)
 		return;
 
+	/* mktime always uses localtime, regardless of the tm_gmtoff field.
+	   It does, however, honour 'tm_isdst'; stupidly. Thankfully, it does
+	   at least tell us the offset it decided to use, so we can compensate
+	   for it */
+	then += tm.tm_gmtoff;
 	then -= offset;
 
 	snprintf(result, maxlen, "%lu %5.5s", then, p);
-- 
dwmw2
Previous: Russ AllberyNext: Edgar Toernig
Message 6 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.