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

Re: [PATCH 1/1] Fix date checking in case if time was not initialized.

From
Mike Gorchak <mike.gorchak.qnx@gmail.com>
Date
Feb 25, 2013, 18:43 UTC
Message-ID
<CAHXAxrMaQRdBxSvNO+no_9d==v0tVnkpXtguTKyfvnm-VfR_xA@mail.gmail.com>
In-Reply-To
<7vzjysxnb1.fsf@alter.siamese.dyndns.org>
Show 8 quoted lines
>> Fix is_date() function failings in detection of correct date in case
>> if time was not properly initialized.
>
> Please explain why this patch is needed and what problem this patch
> is trying to fix (if any) a bit better in the proposed log message.
> For example, on what input do we call this function with partially
> filled *r, and is that an error in the code, or is it an indication
> that the input has only been consumed partially?

function is_date() must not fail if time fields are not set. Currently is_date() invokes tm_to_time_t() which perform check of time fields. With these fixes t0006-date.sh test is no longer fail on these tests:

check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 +0000' check_parse '2008-02-14 20:30:45 -0500' '2008-02-14 20:30:45 -0500' check_parse '2008-02-14 20:30:45 -0015' '2008-02-14 20:30:45 -0015' check_parse '2008-02-14 20:30:45 -5' '2008-02-14 20:30:45 +0000' check_parse '2008-02-14 20:30:45 -5:' '2008-02-14 20:30:45 +0000' check_parse '2008-02-14 20:30:45 -05' '2008-02-14 20:30:45 -0500' check_parse '2008-02-14 20:30:45 -:30' '2008-02-14 20:30:45 +0000' check_parse '2008-02-14 20:30:45 -05:00' '2008-02-14 20:30:45 -0500'

By the way following test is always fails due to absence of EST5 timezone in timezones array in date.c module.

check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 -0500' EST5
> tm_to_time_t() is designed to reject underspecified date input, and
> its callers call is_date() starting with partially filled tm on
> purpose to reject such input. Doesn't "fixing" partially filled tm
> before calling tm_to_time_t() inside is_date() break that logic?

According to logic is_date() have no any relations with time (hours/mins/secs). In the tests described above date is defined first, before time, so at the point when date is checked for correctness time is not defined yet.

Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 9 in “Fix date checking in case if time was not initialized.”
  1. 1/1 Fix date checking in case if time was not initialized.Mike Gorchak, Feb 25, 2013
  2. Junio C HamanoFeb 25, 2013
  3. Mike GorchakFeb 25, 2013
  4. Junio C HamanoFeb 25, 2013
  5. Mike GorchakFeb 25, 2013
  6. Junio C HamanoFeb 25, 2013
  7. Mike GorchakFeb 25, 2013
  8. Junio C HamanoFeb 25, 2013
  9. Mike GorchakFeb 26, 2013

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.