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

Re: [PATCH 0/3] fix local_tzoffset with far-in-future dates

From
Jeff King <peff@peff.net>
Date
Jun 21, 2016, 12:18 UTC
Message-ID
<20160621121813.GA31030@sigill.intra.peff.net>
In-Reply-To
<CAM+g_NtGWRCqaNz1DauZRReem0YPC6CaunHSwfhnB5LpvdGGcQ@mail.gmail.com>
On Mon, Jun 20, 2016 at 11:37:50PM -0700, Norbert Kiesel wrote:
Show 8 quoted lines
> There are more strange things happening with dates.  One example is
> that `git commit --date=@4102444799` produces a commit with the
> correct author date "Thu Dec 31 15:59:59 2099 -0800" (for my local
> timezone which is Americas/Los_Angeles), while `git commit
> --date=@4102444800` produces a commit with "now" as author date, as
> does any other larger number. `date --date=@4102444800` results in
> "Thu Dec 31 16:00:00 PST 2099". So seems 2100-01-01T00:00:00Z is a
> hard limit for git when using this format.

Yes, I noticed that, too. I suspect it comes from the same source; the date parser calls tm_to_time_t at some point which will refuse to handle the date, and we fallback to something else. So certainly there is room for improvement:

  1. We could handle a wider range of dates in tm_to_time_t(). This is
     essentially mktime(), but notice that mktime() was avoided for good
     reasons long ago, so any proposal to just move to that would need
     to figure out all those reasons and whether they are still valid.
  2. We should perhaps be flagging an error here instead of falling back
     to the current time. I suspect this is happening because --date
     falls back to approxidate() when we fail to parse the date (so you
     can say things like "--date=last.friday". Especially for cases with
     "@", which indicate that no approximate parsing is really required.
     Note that using GIT_AUTHOR_DATE _doesn't_ go through the date
     parser, but expects a raw time_t. So that does work for these
     far-future dates.

I'm not planning on working on either of these in the near term, but I'd be happy to review patches if somebody else wants to.

-Peff
Previous: Norbert Kiesel
Message 8 of 8 in “fix local_tzoffset with far-in-future dates”
  1. 0/3 fix local_tzoffset with far-in-future datesJeff King, Jun 20, 2016
  2. 2/3 t0006: test various date formatsJeff King, Jun 20, 2016
  3. 3/3 local_tzoffset: detect errors from tm_to_time_tJeff King, Jun 20, 2016
  4. 1/3 t0006: rename test-date's "show" to "relative"Jeff King, Jun 20, 2016
  5. Junio C HamanoJun 20, 2016
  6. Jeff KingJun 20, 2016
  7. Norbert KieselJun 21, 2016
  8. Jeff KingJun 21, 2016

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.