# [PATCH] Accept dates before 2000/01/01 when specified as seconds since the epoch

6 messages from 2007-06-06 to 2007-06-07. Participants: Johannes Sixt, Junio C Hamano, Sam Vilain, Johannes Schindelin.
Thread: https://gitlist.dev/t/8465

## Johannes Sixt, 2007-06-06 08:11

Subject: [PATCH] Accept dates before 2000/01/01 when specified as seconds since the epoch
Message-ID: <11811175153355-git-send-email-johannes.sixt@telecom.at>
URL: https://gitlist.dev/e/11811175153355-git-send-email-johannes.sixt%40telecom.at

```
Tests with git-filter-branch on a repository that was converted from
CVS and that has commits reaching back to 1999 revealed that it is
necessary to parse dates before 2000/01/01 when they are specified
as seconds since 1970/01/01. There is now still a limit, 100000000,
which is 1973/03/03 09:46:40 UTC, in order to allow that dates are
represented as 8 digits.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 date.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/date.c b/date.c
index a9b59a2..4690371 100644
--- a/date.c
+++ b/date.c
@@ -414,9 +414,11 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
 	num = strtoul(date, &end, 10);
 
 	/*
-	 * Seconds since 1970? We trigger on that for anything after Jan 1, 2000
+	 * Seconds since 1970? We trigger on that for any numbers with
+	 * more than 8 digits. This is because we don't want to rule out
+	 * numbers like 20070606 as a YYYYMMDD date.
 	 */
-	if (num > 946684800) {
+	if (num >= 100000000) {
 		time_t time = num;
 		if (gmtime_r(&time, tm)) {
 			*tm_gmt = 1;
-- 
1.5.2.1.120.gd732

```

## Junio C Hamano, 2007-06-06 08:29

Subject: Re: [PATCH] Accept dates before 2000/01/01 when specified as seconds since the epoch
Message-ID: <7vtztl5vvb.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vtztl5vvb.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <11811175153355-git-send-email-johannes.sixt@telecom.at>

```
I vaguely recall hitting the same issue soon after date.c was
done, and sending in a patch in the same spirit but with
different implementation (I essentially duplicated that "seconds
since epoch" without any cutoff as the last ditch fallback) long
time ago (this was before I took git over; the patch was rejected).

It almost makes me wonder if it is better to introduce a special
syntax to denote "seconds since epoch plus timezone offset" for
our Porcelain use, instead of keeping this arbitrary cut-off
date which nobody can agree on and which forces us to roll back
from time to time.  For one thing, such a syntax would allow us
to talk about a timestamp before the epoch.

Perhaps

	"epoch" [-+] [0-9]+ " " [-+][0-9][0-9][0-9][0-9]

?

```

## Johannes Sixt, 2007-06-06 10:42

Subject: Re: [PATCH] Accept dates before 2000/01/01 when specified as seconds since the epoch
Message-ID: <46668FAD.73D1B73F@eudaptics.com>
URL: https://gitlist.dev/e/46668FAD.73D1B73F%40eudaptics.com
In-Reply-To: <7vtztl5vvb.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> 
> I vaguely recall hitting the same issue soon after date.c was
> done, and sending in a patch in the same spirit but with
> different implementation (I essentially duplicated that "seconds
> since epoch" without any cutoff as the last ditch fallback) long
> time ago (this was before I took git over; the patch was rejected).
> 
> It almost makes me wonder if it is better to introduce a special
> syntax to denote "seconds since epoch plus timezone offset" for
> our Porcelain use, instead of keeping this arbitrary cut-off
> date which nobody can agree on and which forces us to roll back
> from time to time.  For one thing, such a syntax would allow us
> to talk about a timestamp before the epoch.
> 
> Perhaps
> 
>         "epoch" [-+] [0-9]+ " " [-+][0-9][0-9][0-9][0-9]
> 
> ?

OTOH, the previous limit 2000/01/01 was completely arbitrary, while the
new limit 100000000secs has some justification: Numbers with fewer
digits could be mistaken as dates.

-- Hannes

```

## Sam Vilain, 2007-06-07 05:09

Subject: Re: [PATCH] Accept dates before 2000/01/01 when specified as seconds since the epoch
Message-ID: <46679320.6000309@vilain.net>
URL: https://gitlist.dev/e/46679320.6000309%40vilain.net
In-Reply-To: <7vtztl5vvb.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> I vaguely recall hitting the same issue soon after date.c was
> done, and sending in a patch in the same spirit but with
> different implementation (I essentially duplicated that "seconds
> since epoch" without any cutoff as the last ditch fallback) long
> time ago (this was before I took git over; the patch was rejected).
> 
> It almost makes me wonder if it is better to introduce a special
> syntax to denote "seconds since epoch plus timezone offset" for
> our Porcelain use, instead of keeping this arbitrary cut-off
> date which nobody can agree on and which forces us to roll back
> from time to time.  For one thing, such a syntax would allow us
> to talk about a timestamp before the epoch.
> 
> Perhaps
> 
> 	"epoch" [-+] [0-9]+ " " [-+][0-9][0-9][0-9][0-9]

Probably a good idea, though it would break cg-admin-rewritehist.  I had
to make a similar change when working with the Perl history.  Perhaps
allow both?

There is a 10 digit ISO forms (YYYYMMDDHH) and a 9 digit form
(YYYYDDDHH), but these are very rare :)

Sam.

```

## Junio C Hamano, 2007-06-07 05:29

Subject: Re: [PATCH] Accept dates before 2000/01/01 when specified as seconds since the epoch
Message-ID: <7vbqfsqqmq.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vbqfsqqmq.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <46679320.6000309@vilain.net>

```
Sam Vilain <sam@vilain.net> writes:

>> Perhaps
>> 
>> 	"epoch" [-+] [0-9]+ " " [-+][0-9][0-9][0-9][0-9]
>
> Probably a good idea, though it would break cg-admin-rewritehist.

I was saying "additionally allow that to express timestamp even
before the epoch", and existing cg-admin-rewritehist does not
feed such a string, so I do not know how the additionally
allowed format could break it.  Maybe I am missing something?

In any case, "timestamps after March 1973" patch from j6t is
a good change independent from the above one.

```

## Johannes Schindelin, 2007-06-07 05:30

Subject: Re: [PATCH] Accept dates before 2000/01/01 when specified as seconds since the epoch
Message-ID: <Pine.LNX.4.64.0706070629180.4046@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0706070629180.4046%40racer.site
In-Reply-To: <46679320.6000309@vilain.net>

```
Hi,

On Thu, 7 Jun 2007, Sam Vilain wrote:

> Junio C Hamano wrote:
> > I vaguely recall hitting the same issue soon after date.c was
> > done, and sending in a patch in the same spirit but with
> > different implementation (I essentially duplicated that "seconds
> > since epoch" without any cutoff as the last ditch fallback) long
> > time ago (this was before I took git over; the patch was rejected).
> > 
> > It almost makes me wonder if it is better to introduce a special
> > syntax to denote "seconds since epoch plus timezone offset" for
> > our Porcelain use, instead of keeping this arbitrary cut-off
> > date which nobody can agree on and which forces us to roll back
> > from time to time.  For one thing, such a syntax would allow us
> > to talk about a timestamp before the epoch.
> > 
> > Perhaps
> > 
> > 	"epoch" [-+] [0-9]+ " " [-+][0-9][0-9][0-9][0-9]
> 
> Probably a good idea, though it would break cg-admin-rewritehist.

FWIW I don't think we have to care that much about cg-admin-rewritehist, 
since it lives on as git-filter-branch, and we can adapt it as we go.

Ciao,
Dscho

```
