# [PATCH] rev-list: clarify git-log default date format

13 messages from 2023-02-01 to 2023-02-16. Participants: Rafael Dulfer, Junio C Hamano, Jeff King, Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/59176

## Rafael Dulfer, 2023-02-01 15:57

Subject: [PATCH] rev-list: clarify git-log default date format
Message-ID: <20230201155712.86577-1-rafael@dulfer.be>
URL: https://gitlist.dev/e/20230201155712.86577-1-rafael%40dulfer.be

```
From: Rafael Dulfer <rafael.dulfer@gmail.com>

Currently, the documentation is slightly incomplete, not explaining all the differences the default format has with rfc2822. Leading to confusion for people trying to parse the date format outputted by git log

This patch adds 2 more exceptions when compared to rfc2822. Also adds an example of what the format looks like (I originally wanted to specify this in strftime notation, but because of the way day-of-month is formatted this is impossible)

Signed-off-by: Rafael Dulfer <rafael.dulfer@gmail.com>
---
 Documentation/rev-list-options.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index ff68e48406..8bc8475f3e 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -1103,9 +1103,15 @@ format placeholders. When using `-local`, the correct syntax is
 `--date=default` is the default format, and is similar to
 `--date=rfc2822`, with a few exceptions:
 --
-	- there is no comma after the day-of-week
+	- There is no comma after the day-of-week
 
-	- the time zone is omitted when the local time zone is used
+	- The time zone is omitted when the local time zone is used
+
+	- Day-of-month and month are switched around
+
+	- Time-of-day and the year are switched around
+
+As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.
 
 ifdef::git-rev-list[]
 --header::
-- 
2.39.1


```

## Junio C Hamano, 2023-02-01 18:19

Subject: Re: [PATCH] rev-list: clarify git-log default date format
Message-ID: <xmqq5ycl1c6h.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq5ycl1c6h.fsf%40gitster.g
In-Reply-To: <20230201155712.86577-1-rafael@dulfer.be>

```
Rafael Dulfer <rafael@dulfer.be> writes:

> From: Rafael Dulfer <rafael.dulfer@gmail.com>
>
> Currently, the documentation is slightly incomplete, not explaining all the differences the default format has with rfc2822. Leading to confusion for people trying to parse the date format outputted by git log
>
> This patch adds 2 more exceptions when compared to rfc2822. Also adds an example of what the format looks like (I originally wanted to specify this in strftime notation, but because of the way day-of-month is formatted this is impossible)

Overly long lines.

>
> Signed-off-by: Rafael Dulfer <rafael.dulfer@gmail.com>
> ---
>  Documentation/rev-list-options.txt | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
> index ff68e48406..8bc8475f3e 100644
> --- a/Documentation/rev-list-options.txt
> +++ b/Documentation/rev-list-options.txt
> @@ -1103,9 +1103,15 @@ format placeholders. When using `-local`, the correct syntax is
>  `--date=default` is the default format, and is similar to
>  `--date=rfc2822`, with a few exceptions:
>  --
> -	- there is no comma after the day-of-week
> +	- There is no comma after the day-of-week
>  
> -	- the time zone is omitted when the local time zone is used
> +	- The time zone is omitted when the local time zone is used
> +
> +	- Day-of-month and month are switched around
> +
> +	- Time-of-day and the year are switched around
> +
> +As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.

All of the above may technically be correct, but I wonder if it
makes it easier to follow to simply stop saying "is similar to".
That is

    The default format `--date=default` shows a single line with
    three-letter day of the week, three-letter month, day-of-month,
    hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
    year, plus timezone information unless the local time zone is
    used (e.g. "Thu Jan 1 00:00:00 1970 +0000").

or something like that.

```

## Jeff King, 2023-02-01 22:47

Subject: Re: [PATCH] rev-list: clarify git-log default date format
Message-ID: <Y9rr/hfnrV2zmyWf@coredump.intra.peff.net>
URL: https://gitlist.dev/e/Y9rr%2FhfnrV2zmyWf%40coredump.intra.peff.net
In-Reply-To: <xmqq5ycl1c6h.fsf@gitster.g>

```
On Wed, Feb 01, 2023 at 10:19:02AM -0800, Junio C Hamano wrote:

> > -	- there is no comma after the day-of-week
> > +	- There is no comma after the day-of-week
> >  
> > -	- the time zone is omitted when the local time zone is used
> > +	- The time zone is omitted when the local time zone is used
> > +
> > +	- Day-of-month and month are switched around
> > +
> > +	- Time-of-day and the year are switched around
> > +
> > +As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.
> 
> All of the above may technically be correct, but I wonder if it
> makes it easier to follow to simply stop saying "is similar to".
> That is
> 
>     The default format `--date=default` shows a single line with
>     three-letter day of the week, three-letter month, day-of-month,
>     hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>     year, plus timezone information unless the local time zone is
>     used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
> 
> or something like that.

Yes, I agree with your suggestion. When you can explain something as
"like X, but Y" it is helpful when Y is short. When it becomes much
longer, than simply spelling out what X is becomes more helpful.

-Peff

```

## Ævar Arnfjörð Bjarmason, 2023-02-01 22:28

Subject: Re: [PATCH] rev-list: clarify git-log default date format
Message-ID: <230201.864js5q9sv.gmgdl@evledraar.gmail.com>
URL: https://gitlist.dev/e/230201.864js5q9sv.gmgdl%40evledraar.gmail.com
In-Reply-To: <xmqq5ycl1c6h.fsf@gitster.g>

```

On Wed, Feb 01 2023, Junio C Hamano wrote:

> Rafael Dulfer <rafael@dulfer.be> writes:
>
>> From: Rafael Dulfer <rafael.dulfer@gmail.com>
>>
>> Currently, the documentation is slightly incomplete, not explaining
>> all the differences the default format has with rfc2822. Leading to
>> confusion for people trying to parse the date format outputted by
>> git log
>>
>> This patch adds 2 more exceptions when compared to rfc2822. Also
>> adds an example of what the format looks like (I originally wanted
>> to specify this in strftime notation, but because of the way
>> day-of-month is formatted this is impossible)
>
> Overly long lines.
>
>>
>> Signed-off-by: Rafael Dulfer <rafael.dulfer@gmail.com>
>> ---
>>  Documentation/rev-list-options.txt | 10 ++++++++--
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
>> index ff68e48406..8bc8475f3e 100644
>> --- a/Documentation/rev-list-options.txt
>> +++ b/Documentation/rev-list-options.txt
>> @@ -1103,9 +1103,15 @@ format placeholders. When using `-local`, the correct syntax is
>>  `--date=default` is the default format, and is similar to
>>  `--date=rfc2822`, with a few exceptions:
>>  --
>> -	- there is no comma after the day-of-week
>> +	- There is no comma after the day-of-week
>>  
>> -	- the time zone is omitted when the local time zone is used
>> +	- The time zone is omitted when the local time zone is used
>> +
>> +	- Day-of-month and month are switched around
>> +
>> +	- Time-of-day and the year are switched around
>> +
>> +As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.
>
> All of the above may technically be correct, but I wonder if it
> makes it easier to follow to simply stop saying "is similar to".
> That is
>
>     The default format `--date=default` shows a single line with
>     three-letter day of the week, three-letter month, day-of-month,
>     hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>     year, plus timezone information unless the local time zone is
>     used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
>
> or something like that.

I think that following such a description in prose is still more
confusing than just showing an example. E.g. we could say:
	
	Assuming a user in timezone +0200 (Central Europe) values of
	these `--date` argument would produce:
	
	|---------------+--------------------------------|
	| rfc2822       | Thu, 7 Apr 2005 15:13:13 -0700 |
	| rfc2822-local | Fri, 8 Apr 2005 00:13:13 +0200 |
	| default       | Thu Apr 7 15:13:13 2005 -0700  |
	| default-local | Fri Apr 8 00:13:13 2005        |
	|---------------+--------------------------------|
	
In particular your example says "unless the local time zone is used",
but then shows an example that's 'default', not 'default-local'.

```

## Junio C Hamano, 2023-02-01 22:58

Subject: Re: [PATCH] rev-list: clarify git-log default date format
Message-ID: <xmqqy1phxabi.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqy1phxabi.fsf%40gitster.g
In-Reply-To: <230201.864js5q9sv.gmgdl@evledraar.gmail.com>

```
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>> That is
>>
>>     The default format `--date=default` shows a single line with
>>     three-letter day of the week, three-letter month, day-of-month,
>>     hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>>     year, plus timezone information unless the local time zone is
>>     used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
>>
>> or something like that.
>
> I think that following such a description in prose is still more
> confusing than just showing an example. E.g. we could say:
> 	
> 	Assuming a user in timezone +0200 (Central Europe) values of

Add "on day X at time Y" here, and I'd buy that ;-)

> 	these `--date` argument would produce:
> 	
> 	|---------------+--------------------------------|
> 	| rfc2822       | Thu, 7 Apr 2005 15:13:13 -0700 |
> 	| rfc2822-local | Fri, 8 Apr 2005 00:13:13 +0200 |
> 	| default       | Thu Apr 7 15:13:13 2005 -0700  |
> 	| default-local | Fri Apr 8 00:13:13 2005        |
> 	|---------------+--------------------------------|


```

## Rafael Dulfer, 2023-02-02 11:37

Subject: Re: [PATCH] rev-list: clarify git-log default date format
Message-ID: <d9fc8688-bbf1-96c2-07bf-a12fe38625a9@dulfer.be>
URL: https://gitlist.dev/e/d9fc8688-bbf1-96c2-07bf-a12fe38625a9%40dulfer.be
In-Reply-To: <xmqqy1phxabi.fsf@gitster.g>

```
> Add "on day X at time Y" here, and I'd buy that 😉

Feels to me that adding "on day X at time Y" is a bit superfluous, since 
it's quite obvious from the examples, but I guess it can't hurt to be exact.

I think it would be a good idea to still have _some_ text for 
`--date=default`, just so the structure of the sections stays the same 
over all the date options. Maybe just something simple like. 
"`--date=default` is the default format. It is a custom format based on 
rfc2822". And then below that we have the table (which is more a 
conclusion to the section, as it provides examples for a few, more 
unclear, formats)

On 01/02/2023 23:58, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>>> That is
>>>
>>>      The default format `--date=default` shows a single line with
>>>      three-letter day of the week, three-letter month, day-of-month,
>>>      hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>>>      year, plus timezone information unless the local time zone is
>>>      used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
>>>
>>> or something like that.
>> I think that following such a description in prose is still more
>> confusing than just showing an example. E.g. we could say:
>> 	
>> 	Assuming a user in timezone +0200 (Central Europe) values of
> Add "on day X at time Y" here, and I'd buy that ;-)
>
>> 	these `--date` argument would produce:
>> 	
>> 	|---------------+--------------------------------|
>> 	| rfc2822       | Thu, 7 Apr 2005 15:13:13 -0700 |
>> 	| rfc2822-local | Fri, 8 Apr 2005 00:13:13 +0200 |
>> 	| default       | Thu Apr 7 15:13:13 2005 -0700  |
>> 	| default-local | Fri Apr 8 00:13:13 2005        |
>> 	|---------------+--------------------------------|

```

## Junio C Hamano, 2023-02-02 16:17

Subject: Re: [PATCH] rev-list: clarify git-log default date format
Message-ID: <xmqqfsbovy7u.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqfsbovy7u.fsf%40gitster.g
In-Reply-To: <d9fc8688-bbf1-96c2-07bf-a12fe38625a9@dulfer.be>

```
Rafael Dulfer <rafael@dulfer.be> writes:

> like. "`--date=default` is the default format. It is a custom format
> based on rfc2822".

But the thing is it is *not* custom based on rfc2822.  The default
format came first, 2822 much later.  If I have to guess (and I
shouldn't because I was around back when we invented that format,
but I am lazy and my recollecion hazy), it came straight from the
result of ctime() but with timezone info appended at the end.


```

## Junio C Hamano, 2023-02-02 16:53

Subject: Re: [PATCH] rev-list: clarify git-log default date format
Message-ID: <xmqqsffouhys.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqsffouhys.fsf%40gitster.g
In-Reply-To: <xmqqfsbovy7u.fsf@gitster.g>

```
Junio C Hamano <gitster@pobox.com> writes:

> Rafael Dulfer <rafael@dulfer.be> writes:
>
>> like. "`--date=default` is the default format. It is a custom format
>> based on rfc2822".
>
> But the thing is it is *not* custom based on rfc2822.  The default
> format came first, 2822 much later.  If I have to guess (and I
> shouldn't because I was around back when we invented that format,
> but I am lazy and my recollecion hazy), it came straight from the
> result of ctime() but with timezone info appended at the end.

It indeed was modeled after ctime() in f80cd783 (date.c: add
"show_date()" function., 2005-05-06).

    date.c: add "show_date()" function.
    
    Kind of like ctime(), but not as broken.

```

## Junio C Hamano, 2023-02-16 00:42

Subject: [PATCH v2] rev-list: clarify git-log default date format
Message-ID: <xmqqcz6av3ta.fsf_-_@gitster.g>
URL: https://gitlist.dev/e/xmqqcz6av3ta.fsf_-_%40gitster.g
In-Reply-To: <xmqqsffouhys.fsf@gitster.g>

```
The documentation mistakenly said that the default format was
similar to RFC 2822 format and tried to specify it by enumerating
differences, which had two problems:

 * There are some more differences from the 2822 format that are not
   mentioned; worse yet

 * The default format is not modeled after RFC 2822 format at all.
   As can be seen in f80cd783 (date.c: add "show_date()" function.,
   2005-05-06), it is a derivative of ctime(3) format.

Stop saying that it is similar to RFC 2822, and rewrite the
description to explain the format without requiring the reader to
know any other format.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * The discussion stalled and the topic was left in limbo for a few
   weeks.  Let's attempt to reboot it instead of silently waiting
   for a rerolled version from the original author.

 Documentation/rev-list-options.txt | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index ff68e48406..9ae7ccdaa9 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -1100,12 +1100,11 @@ preferred format.  See the `strftime` manual for a complete list of
 format placeholders. When using `-local`, the correct syntax is
 `--date=format-local:...`.
 
-`--date=default` is the default format, and is similar to
-`--date=rfc2822`, with a few exceptions:
---
-	- there is no comma after the day-of-week
-
-	- the time zone is omitted when the local time zone is used
+`--date=default` is the default format, and is based on ctime(3)
+output.  It shows a single line with three-letter day of the week,
+three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS"
+format, followed by 4-digit year, plus timezone information, unless
+the local time zone is used, e.g. `Thu Jan 1 00:00:00 1970 +0000`.
 
 ifdef::git-rev-list[]
 --header::
-- 
2.39.2-456-gb1485644f9


```

## Jeff King, 2023-02-16 02:15

Subject: Re: [PATCH v2] rev-list: clarify git-log default date format
Message-ID: <Y+2R2qIVQG9hJpEA@coredump.intra.peff.net>
URL: https://gitlist.dev/e/Y%2B2R2qIVQG9hJpEA%40coredump.intra.peff.net
In-Reply-To: <xmqqcz6av3ta.fsf_-_@gitster.g>

```
On Wed, Feb 15, 2023 at 04:42:25PM -0800, Junio C Hamano wrote:

> The documentation mistakenly said that the default format was
> similar to RFC 2822 format and tried to specify it by enumerating
> differences, which had two problems:
> 
>  * There are some more differences from the 2822 format that are not
>    mentioned; worse yet
> 
>  * The default format is not modeled after RFC 2822 format at all.
>    As can be seen in f80cd783 (date.c: add "show_date()" function.,
>    2005-05-06), it is a derivative of ctime(3) format.
> 
> Stop saying that it is similar to RFC 2822, and rewrite the
> description to explain the format without requiring the reader to
> know any other format.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  * The discussion stalled and the topic was left in limbo for a few
>    weeks.  Let's attempt to reboot it instead of silently waiting
>    for a rerolled version from the original author.

Thanks for keeping this moving. The proposed text looks great to me.

-Peff

```

## Junio C Hamano, 2023-02-16 02:58

Subject: Re: [PATCH v2] rev-list: clarify git-log default date format
Message-ID: <xmqqfsb6tixy.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqfsb6tixy.fsf%40gitster.g
In-Reply-To: <Y+2R2qIVQG9hJpEA@coredump.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On Wed, Feb 15, 2023 at 04:42:25PM -0800, Junio C Hamano wrote:
>
>> The documentation mistakenly said that the default format was
>> similar to RFC 2822 format and tried to specify it by enumerating
>> differences, which had two problems:
>> 
>>  * There are some more differences from the 2822 format that are not
>>    mentioned; worse yet
>> 
>>  * The default format is not modeled after RFC 2822 format at all.
>>    As can be seen in f80cd783 (date.c: add "show_date()" function.,
>>    2005-05-06), it is a derivative of ctime(3) format.
>> 
>> Stop saying that it is similar to RFC 2822, and rewrite the
>> description to explain the format without requiring the reader to
>> know any other format.
>> 
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>> ---
>>  * The discussion stalled and the topic was left in limbo for a few
>>    weeks.  Let's attempt to reboot it instead of silently waiting
>>    for a rerolled version from the original author.
>
> Thanks for keeping this moving. The proposed text looks great to me.

Thanks, but the formatting is broken, and needs a line with "--" on
it at the end.  What I will queue on 'seen' already has the
correction.

```

## Junio C Hamano, 2023-02-16 16:29

Subject: [PATCH v3] rev-list: clarify git-log default date format
Message-ID: <xmqqzg9dshei.fsf_-_@gitster.g>
URL: https://gitlist.dev/e/xmqqzg9dshei.fsf_-_%40gitster.g
In-Reply-To: <xmqqcz6av3ta.fsf_-_@gitster.g>

```
The documentation mistakenly said that the default format was
similar to RFC 2822 format and tried to specify it by enumerating
differences, which had two problems:

 * There are some more differences from the 2822 format that are not
   mentioned; worse yet

 * The default format is not modeled after RFC 2822 format at all.
   As can be seen in f80cd783 (date.c: add "show_date()" function.,
   2005-05-06), it is a derivative of ctime(3) format.

Stop saying that it is similar to RFC 2822, and rewrite the
description to explain the format without requiring the reader to
know any other format.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * The same text as the previous one; only to correct the lack of
   "--" at the end in v2 that broke the formatting toolchain.

 Documentation/rev-list-options.txt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index ff68e48406..0d90d5b154 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -1100,12 +1100,12 @@ preferred format.  See the `strftime` manual for a complete list of
 format placeholders. When using `-local`, the correct syntax is
 `--date=format-local:...`.
 
-`--date=default` is the default format, and is similar to
-`--date=rfc2822`, with a few exceptions:
+`--date=default` is the default format, and is based on ctime(3)
+output.  It shows a single line with three-letter day of the week,
+three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS"
+format, followed by 4-digit year, plus timezone information, unless
+the local time zone is used, e.g. `Thu Jan 1 00:00:00 1970 +0000`.
 --
-	- there is no comma after the day-of-week
-
-	- the time zone is omitted when the local time zone is used
 
 ifdef::git-rev-list[]
 --header::
-- 
2.39.2-501-gd9d677b2d8



```

## Jeff King, 2023-02-16 17:24

Subject: Re: [PATCH v3] rev-list: clarify git-log default date format
Message-ID: <Y+5m6qIx1xsy2Scw@coredump.intra.peff.net>
URL: https://gitlist.dev/e/Y%2B5m6qIx1xsy2Scw%40coredump.intra.peff.net
In-Reply-To: <xmqqzg9dshei.fsf_-_@gitster.g>

```
On Thu, Feb 16, 2023 at 08:29:25AM -0800, Junio C Hamano wrote:

>  * The same text as the previous one; only to correct the lack of
>    "--" at the end in v2 that broke the formatting toolchain.

Thanks. I looked at this version under doc-diff as well as the HTML
version and confirmed that it looks good (which I'm sure you also did at
this point ;) ).

-Peff

```
