# Inconsistency between git-log documentation and behavior regarding default date format.

3 messages from 2023-01-24 to 2023-02-01. Participants: Rafael Dulfer, Andrei Rybak, Jeff King.
Thread: https://gitlist.dev/t/59146

## Rafael Dulfer, 2023-01-24 15:09

Subject: Inconsistency between git-log documentation and behavior regarding default date format.
Message-ID: <9c3428f6-a254-13b4-046d-6e20ef602aef@dulfer.be>
URL: https://gitlist.dev/e/9c3428f6-a254-13b4-046d-6e20ef602aef%40dulfer.be
In-Reply-To: <793c8116-f7ea-eef2-6979-231c3e94639a@dulfer.be>

```
The Git documentation 
<https://www.git-scm.com/docs/git-log#Documentation/git-log.txt---dateltformatgt> states 
that if no date format is given (or --date=default is given), the date 
format is similar to rfc2822 except of a few exceptions, of which those 
listed are:

   * There is no comma after the day-of-week
   * The time zone is omitted when the local time zone is used

However, if we were to compare the two date formats, you can see another 
difference:

git log --default  ->  Tue Jan 24 11:03:47 2023 +0100
git log --rfc          ->  Tue, 24 Jan 2023 11:03:47 +0100

With the default, the month and day-of-month are switched around. From 
my own quick investigation, this behavior occurs because of the 
statement found at date.c#L266 
<https://github.com/git/git/blob/56c8fb1e95377900ec9d53c07886022af0a5d3c2/date.c#L266> 
wherein the month is inserted before the day-of-month. I am unsure which 
behavior is exactly intended and whether this discrepancy was known, but 
it would probably be a good idea to have a note of it in the documentation.

```

## Andrei Rybak, 2023-02-01 01:33

Subject: Re: Inconsistency between git-log documentation and behavior regarding default date format.
Message-ID: <8d72f484-6a72-87f9-44f1-3a38471201db@gmail.com>
URL: https://gitlist.dev/e/8d72f484-6a72-87f9-44f1-3a38471201db%40gmail.com
In-Reply-To: <9c3428f6-a254-13b4-046d-6e20ef602aef@dulfer.be>

```
On 24/01/2023 16:09, Rafael Dulfer wrote:
> The Git documentation 
> <https://www.git-scm.com/docs/git-log#Documentation/git-log.txt---dateltformatgt> states that if no date format is given (or --date=default is given), the date format is similar to rfc2822 except of a few exceptions, of which those listed are:
> 
>    * There is no comma after the day-of-week
>    * The time zone is omitted when the local time zone is used
> 
> However, if we were to compare the two date formats, you can see another 
> difference:
> 
> git log --default  ->  Tue Jan 24 11:03:47 2023 +0100
> git log --rfc          ->  Tue, 24 Jan 2023 11:03:47 +0100

It seems that options in these samples were mistyped. They are missing 
the "--date=" part:


     $ git log -1 --date=default  master | grep 'Date:'
     Date:   Sat Jan 21 16:35:14 2023 -0800

     $ git log -1 --date=rfc2822   master | grep 'Date:'
     Date:   Sat, 21 Jan 2023 16:35:14 -0800

> 
> With the default, the month and day-of-month are switched around. From 
> my own quick investigation, this behavior occurs because of the 
> statement found at date.c#L266 
> <https://github.com/git/git/blob/56c8fb1e95377900ec9d53c07886022af0a5d3c2/date.c#L266> wherein the month is inserted before the day-of-month. I am unsure which behavior is exactly intended and whether this discrepancy was known, but it would probably be a good idea to have a note of it in the documentation.

Indeed, the description of the option (which comes from 
Documentation/rev-list-options.txt) doesn't describe all differences
between --date=default and --date=rfc2822.

A fuller list could be:

     * There is no comma after the day-of-week
     * 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

CC'ing Peff, who wrote the list of exceptions in add00ba2de (date: make 
"local" orthogonal to date format, 2015-09-03).

```

## Jeff King, 2023-02-01 11:51

Subject: Re: Inconsistency between git-log documentation and behavior regarding default date format.
Message-ID: <Y9pSWCS1BNkHt+Mw@coredump.intra.peff.net>
URL: https://gitlist.dev/e/Y9pSWCS1BNkHt%2BMw%40coredump.intra.peff.net
In-Reply-To: <8d72f484-6a72-87f9-44f1-3a38471201db@gmail.com>

```
On Wed, Feb 01, 2023 at 02:33:49AM +0100, Andrei Rybak wrote:

> Indeed, the description of the option (which comes from
> Documentation/rev-list-options.txt) doesn't describe all differences
> between --date=default and --date=rfc2822.
> 
> A fuller list could be:
> 
>     * There is no comma after the day-of-week
>     * 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
> 
> CC'ing Peff, who wrote the list of exceptions in add00ba2de (date: make
> "local" orthogonal to date format, 2015-09-03).

I don't think I had any particular reason to omit those other
differences. I probably just didn't notice them. Patches welcome.

-Peff

```
