git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH v2] Add 'human' date format

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 11, 2018, 20:49 UTC
Message-ID
<CA+55aFym5aSudSHiVA=VmvoY=WFytUqficLQCE4Sd_urjwKqPw@mail.gmail.com>
In-Reply-To
<CACayv=ifE5BQVtxXCVEhS3uO7iz1z+ZPrF3J_n=e-uoYOpwNtA@mail.gmail.com>
On Wed, Jul 11, 2018 at 1:34 PM Andrei Rybak <rybak.a.v@gmail.com> wrote:
Show 5 quoted lines
>
> > +     int human_tz = -1;
>
> Is -1 an OK initial value for timezone if local_time_tzoffset returns
> negative values as well? It looks like it doesn't matter for from functional

The value was intentionally picked to *not* be a valid timezone value, so that the comparison of "human_tz == tz" would always fail if DATE_HUMAN is not selected.

But it could be anything else invalid, of course. It could be MAX_INT or something like that.

By picking something that isn't possibly a real timezone value, late code can do things like

        hide.tz = local || tz == human_tz;
without worrying about whther it's really DATE_HUMAN or not.
The clearing of "human_tm" is done for a similar reason: the code does
        hide.year = tm->tm_year == human_tm->tm_year;

(and then later just checks "if (human_tm->tm_year)") knowing that a non-zero tm_year will only ever happen for human_tz (and that 1900 is not a valid git date, even though I guess in theory you could do it).

               Linus
Previous: Junio C HamanoNext: Linus Torvalds
Message 8 of 14 in “Add 'human' date format”
  1. Add 'human' date formatLinus Torvalds, Jul 7, 2018
  2. Linus TorvaldsJul 7, 2018
  3. Linus TorvaldsJul 7, 2018
  4. Add 'human' date formatLinus Torvalds, Jul 7, 2018
  5. Andrei RybakJul 11, 2018
  6. Andrei RybakJul 11, 2018
  7. Junio C HamanoJul 11, 2018
  8. Linus TorvaldsJul 11, 2018
  9. Linus TorvaldsJul 11, 2018
  10. Ævar Arnfjörð BjarmasonJul 11, 2018
  11. Linus TorvaldsJul 11, 2018
  12. Junio C HamanoJul 24, 2018
  13. Linus TorvaldsJul 24, 2018
  14. Stephen P. SmithNov 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.