{"thread":{"id":"65713","subject":"[BUG] internal date format does not accept small unix timestamps","startedAt":"2026-05-29T11:53:33Z","lastAt":"2026-05-31T08:30:02Z","messageCount":6,"participants":["Luna Schwalbe","Kristoffer Haugsbakk","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"544265","messageId":"fffe0ea9-baea-47cc-b354-5be4fff08983@luna.gl","threadId":"65713","inReplyTo":null,"subject":"[BUG] internal date format does not accept small unix timestamps","fromName":"Luna Schwalbe","fromEmail":"dev@luna.gl","sentAt":"2026-05-29T11:51:23Z","receivedAt":"2026-05-29T11:53:33Z","isPatch":false,"body":"While trying to create some test commits, I noticed the following issue:\n\nGIT_AUTHOR_DATE and GIT_COMMITTER_DATE should accept the \"Git internal \nformat\" (displayed by git log with --date=raw), but this fails for small \nunix timestamps. A quick binary search indicates that it happens when \nthe unix timestamp is below 100000000 (9 digits).\n\nSo for example, GIT_AUTHOR_DATE='99999999 +0000' fails with \"fatal: \ninvalid date format\", while GIT_AUTHOR_DATE='100000000 +0000' works as \nexpected.\nIt seems to be unaffected by the choice of timezone offset.\nPadding the timestamp with zeroes also does not change the behavior.\n\nThe --date option does accept all the values, but interprets them \nwrongly and gives bogus results (most of them time it seems to act as if \nno date option was given, using the current system time, but with some \ninputs I've also observed things like \"current date&time but set the \nyear to 2000\").\n\nI tested everything with git built from commit \n2f8565e1d14d2de4cfbc9da0132131bf0d0dc087.\n\nLuna\n"},{"id":"544268","messageId":"a8e51dda-7b1d-426e-9af9-cf856c42342d@app.fastmail.com","threadId":"65713","inReplyTo":"fffe0ea9-baea-47cc-b354-5be4fff08983@luna.gl","subject":"Re: [BUG] internal date format does not accept small unix timestamps","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-05-29T12:50:02Z","receivedAt":"2026-05-29T12:50:54Z","isPatch":false,"body":"On Fri, May 29, 2026, at 13:51, Luna Schwalbe wrote:\n> While trying to create some test commits, I noticed the following issue:\n>\n> GIT_AUTHOR_DATE and GIT_COMMITTER_DATE should accept the \"Git internal\n> format\" (displayed by git log with --date=raw), but this fails for small\n> unix timestamps. A quick binary search indicates that it happens when\n> the unix timestamp is below 100000000 (9 digits).\n>\n> So for example, GIT_AUTHOR_DATE='99999999 +0000' fails with \"fatal:\n> invalid date format\", while GIT_AUTHOR_DATE='100000000 +0000' works as\n> expected.\n> It seems to be unaffected by the choice of timezone offset.\n> Padding the timestamp with zeroes also does not change the behavior.\n>\n> The --date option does accept all the values, but interprets them\n> wrongly and gives bogus results (most of them time it seems to act as if\n> no date option was given, using the current system time, but with some\n> inputs I've also observed things like \"current date&time but set the\n> year to 2000\").\n>\n> I tested everything with git built from commit\n> 2f8565e1d14d2de4cfbc9da0132131bf0d0dc087.\n\nApparently you need `@` in front for small Unix Epoch values. `@0 +0000`\n"},{"id":"544270","messageId":"08a04d91-af90-44dd-b28f-f3d5b9e77413@luna.gl","threadId":"65713","inReplyTo":"a8e51dda-7b1d-426e-9af9-cf856c42342d@app.fastmail.com","subject":"Re: [BUG] internal date format does not accept small unix timestamps","fromName":"Luna Schwalbe","fromEmail":"dev@luna.gl","sentAt":"2026-05-29T14:52:38Z","receivedAt":"2026-05-29T14:52:44Z","isPatch":false,"body":" > Apparently you need `@` in front for small Unix Epoch values. `@0 +0000`\n\nThat is wonderful, thank you so much, I somehow did not find this small \ndetail anywhere.\n\nMaybe it could be added to Documentation/date-formats.adoc?\n\nLuna\n"},{"id":"544293","messageId":"xmqq7bolg762.fsf@gitster.g","threadId":"65713","inReplyTo":"08a04d91-af90-44dd-b28f-f3d5b9e77413@luna.gl","subject":"Re: [BUG] internal date format does not accept small unix timestamps","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-05-29T22:52:37Z","receivedAt":"2026-05-29T22:52:40Z","isPatch":false,"body":"Luna Schwalbe <dev@luna.gl> writes:\n\n>  > Apparently you need `@` in front for small Unix Epoch values. `@0 +0000`\n>\n> That is wonderful, thank you so much, I somehow did not find this small \n> detail anywhere.\n>\n> Maybe it could be added to Documentation/date-formats.adoc?\n>\n> Luna\n\nGood suggestion.\n\nThis was introduced in 116eb3ab (parse_date(): allow ancient\ngit-timestamp, 2012-02-02) and 2c733fb2 (parse_date(): '@' prefix\nforces git-timestamp, 2012-02-02) to allow specifying \"ancient\"\ntimestamps (like 0 +0000) without conflicting with YYYYMMDD date\nformats.  I do not think neither commit added documentation for this\n'@' prefix, and Documentation/date-formats would be an excellent\nplace to do so.\n\nCare to whip up a patch?\n\nThanks.\n"},{"id":"544295","messageId":"xmqqpl2de41m.fsf@gitster.g","threadId":"65713","inReplyTo":"xmqq7bolg762.fsf@gitster.g","subject":"doc: document '@' prefix for raw timestamps","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-05-30T07:43:01Z","receivedAt":"2026-05-30T07:43:04Z","isPatch":false,"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> This was introduced in 116eb3ab (parse_date(): allow ancient\n> git-timestamp, 2012-02-02) and 2c733fb2 (parse_date(): '@' prefix\n> forces git-timestamp, 2012-02-02) to allow specifying \"ancient\"\n> timestamps (like 0 +0000) without conflicting with YYYYMMDD date\n> formats.  I do not think neither commit added documentation for this\n> '@' prefix, and Documentation/date-formats would be an excellent\n> place to do so.\n>\n> Care to whip up a patch?\n\nIt might look something like this.\n\n----- >8 -----\n\nThe Git internal date format `<unix-timestamp> <time-zone-offset>`\nfails to parse when the timestamp is less than 100,000,000 (fewer\nthan 9 digits). This happens because the parser attempts to guess\nthe format, and 8-digit numbers are interpreted as YYYYMMDD dates.\n\nTo force the parser to interpret the value as a raw timestamp, it\nmust be prefixed with `@` (e.g., `@0 +0000`). This behavior was\nintroduced in 2c733fb24c (parse_date(): '@' prefix forces\ngit-timestamp, 2012-02-02) but was never documented.\n\nDocument the `@` prefix in `Documentation/date-formats.adoc` to\nmake this behavior explicit. Also add test cases to\n`t/t0006-date.sh` to verify and demonstrate the difference\nbetween prefixed and unprefixed small timestamps (e.g.,\n`@20000101` vs `20000101`).\n---\ndiff --git a/Documentation/date-formats.adoc b/Documentation/date-formats.adoc\nindex e24517c496..93fd36449c 100644\n--- a/Documentation/date-formats.adoc\n+++ b/Documentation/date-formats.adoc\n@@ -9,6 +9,13 @@ Git internal format::\n \t`<unix-timestamp>` is the number of seconds since the UNIX epoch.\n \t`<time-zone-offset>` is a positive or negative offset from UTC.\n \tFor example CET (which is 1 hour ahead of UTC) is `+0100`.\n++\n+It is safer to prepend the `<unix-timestamp>` with `@`\n+(e.g., `@0 +0000`), which forces Git to interpret it as a raw\n+timestamp even if it looks like another format (like `YYYYMMDD`).\n+This is required for timestamps less than 100,000,000 (which have\n+fewer than 9 digits) to avoid confusion with other date formats.\n+\n \n RFC 2822::\n \tThe standard date format as described by RFC 2822, for example\ndiff --git a/t/t0006-date.sh b/t/t0006-date.sh\nindex 53ced36df4..e11c659716 100755\n--- a/t/t0006-date.sh\n+++ b/t/t0006-date.sh\n@@ -138,6 +138,14 @@ check_parse '1969-12-31 23:59:59 Z' bad\n check_parse '1969-12-31 23:59:59 +11' bad\n check_parse '1969-12-31 23:59:59 -11' bad\n \n+# pathologically small or easily confused raw timestamps\n+check_parse '@99999999 +0000' '1973-03-03 09:46:39 +0000'\n+check_parse '@0 +0000' '1970-01-01 00:00:00 +0000'\n+check_parse '99999999 +0000' bad\n+check_parse '20000101 +0000' '2000-01-01 00:00:00 +0000'\n+check_parse '@20000101 +0000' '1970-08-20 11:35:01 +0000'\n+\n+\n REQUIRE_64BIT_TIME=HAVE_64BIT_TIME\n check_parse '2099-12-31 23:59:59' '2099-12-31 23:59:59 +0000'\n check_parse '2099-12-31 23:59:59 +00' '2099-12-31 23:59:59 +0000'\n"},{"id":"544315","messageId":"ca8e1a7c-1d9b-4af3-95be-fcb5c2e24d80@luna.gl","threadId":"65713","inReplyTo":"xmqqpl2de41m.fsf@gitster.g","subject":"Re: doc: document '@' prefix for raw timestamps","fromName":"Luna Schwalbe","fromEmail":"dev@luna.gl","sentAt":"2026-05-31T08:29:54Z","receivedAt":"2026-05-31T08:30:02Z","isPatch":false,"body":" >> This was introduced in 116eb3ab (parse_date(): allow ancient\n>> git-timestamp, 2012-02-02) and 2c733fb2 (parse_date(): '@' prefix\n>> forces git-timestamp, 2012-02-02) to allow specifying \"ancient\"\n>> timestamps (like 0 +0000) without conflicting with YYYYMMDD date\n>> formats.  I do not think neither commit added documentation for this\n>> '@' prefix, and Documentation/date-formats would be an excellent\n>> place to do so.\n>>\n>> Care to whip up a patch?\n> It might look something like this.\n\nThanks! And sure, I'll try to submit something later; this will be my \nfirst time using the send-mail workflow, I hope I don't mess anything up.\n"}]}