From: Jeff King <peff@peff.net>
To: the.tester@mac.com
Cc: git@vger.kernel.org
Subject: Re: Date and time processing issue
Date: Sun, 4 Aug 2024 21:14:23 -0400 [thread overview]
Message-ID: <20240805011423.GA68394@coredump.intra.peff.net> (raw)
In-Reply-To: <B896574C-A150-45AE-A636-ADA9ADF3255A@mac.com>
On Fri, Aug 02, 2024 at 11:46:30AM +0200, the.tester@mac.com wrote:
> To me, the error message is at least misleading.
> It also seem to be hidin the underlying issue that git (commit)
> doesn’t accept time stamps before the epoch.
>
> Given that 1970-01-01 00:00:00 seems to be the lower boundary, I
> expected some time in 2038-01-19 to be the corresponding upper
> boundary.
We use an unsigned value (hence the lower bound being at the epoch), so
in a 32-bit world the high boundary would be 2106. But we actually use
uintmax_t these days, so it's effectively infinite (even no 32-bit
systems, there should be _some_ larger type available). But...
> However the same error message is given when the date is >= 2100-01-01
> 00:00:00.
...the sloppy tm_to_time_t() code does not handle conversions past 2100
due to the leap year skip there. There's more discussion in:
https://lore.kernel.org/git/20240604093345.GA1279521@coredump.intra.peff.net/
That message mentions patches to handle negative timestamps completely.
You can see them here:
https://github.com/peff/git/jk/time-negative-wip
It works fine on Linux, but IIRC I got stuck on the system time-handling
functions of Windows being unhappy. Probably solvable by implementing
more custom code.
If you're interested in trying to push it over the finish line, I'd be
happy to discuss it.
Although...
> I’d also expect that correctly formatted time stamps containing valid
> date & time information should be processed correctly. (at least for
> dates after Friday 15 October 1582 (as the day before was Thursday 4
> October 1582)
I'm not sure how my implementation would handle this. The tm_to_time_t()
fallback doesn't know anything about historical calendar shifts, and
going in the reverse direction would depend on your system gmtime(). So
probably:
- if you feed a correct epoch timestamp for October 4th (e.g., "git
commit --date=@-") you may or may not get the right result. Certainly
on Windows if we have to use fallback code you wouldn't. But even GNU
date doesn't seem to handle this:
$ date --date=@-12219361438
Thu Oct 14 00:00:00 LMT 1582
- we'd always use custom code for going the other way. So:
git commit --date=1582-10-04
would give you an epoch 11 days before the 15th, not 1 day.
Even still, IMHO handling negative timestamps at all would be a huge
improvement over the status quo. And we should be correct down to the
second for "recent" stuff (like say, code written in the 1960's).
-Peff
prev parent reply other threads:[~2024-08-05 1:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 9:46 Date and time processing issue the.tester
2024-08-02 16:19 ` Junio C Hamano
2024-08-04 14:15 ` the.tester
2024-08-05 1:14 ` Jeff King [this message]
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=20240805011423.GA68394@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=the.tester@mac.com \
/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