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

Re: [PATCH v2] date.c: allow ISO 8601 reduced precision times

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 13, 2023, 19:50 UTC
Message-ID
<xmqqlem62oyr.fsf@gitster.g>
In-Reply-To
<20230111001003.10916-1-congdanhqx@gmail.com>
Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
Show 41 quoted lines
> ISO 8601 permits "reduced precision" time representations to omit the
> seconds value or both the minutes and the seconds values.  The
> abbreviate times could look like 17:45 or 1745 to omit the seconds,
> or simply as 17 to omit both the minutes and the seconds.
>
> parse_date_basic accepts the 17:45 format but it rejects the other two.
> Change it to accept 4-digit and 2-digit time values when they follow a
> recognized date and a 'T'.
>
> Before this change:
>
> $ TZ=UTC test-tool date approxidate 2022-12-13T23:00 2022-12-13T2300 2022-12-13T23
> 2022-12-13T23:00 -> 2022-12-13 23:00:00 +0000
> 2022-12-13T2300 -> 2022-12-13 23:54:13 +0000
> 2022-12-13T23 -> 2022-12-13 23:54:13 +0000
>
> After this change:
>
> $ TZ=UTC helper/test-tool date approxidate 2022-12-13T23:00 2022-12-13T2300 2022-12-13T23
> 2022-12-13T23:00 -> 2022-12-13 23:00:00 +0000
> 2022-12-13T2300 -> 2022-12-13 23:00:00 +0000
> 2022-12-13T23 -> 2022-12-13 23:00:00 +0000
>
> Note: ISO 8601 also allows reduced precision date strings such as
> "2022-12" and "2022". This patch does not attempt to address these.
>
> Reported-by: Pat LaVarre <plavarre@purestorage.com>
> Signed-off-by: Phil Hord <phil.hord@gmail.com>
> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> ---
>
> Since this is a complete re-implementation from Phil Hord's version.
> I'm reassigning the author to me.
>
> This version change the implementation to only treat the string as ISO8601 if
> a 'T' existed and date has been parsed. I also added a test for parsing
> RFC-822, which Hord accidentally broke.
>
> The commit message has been changed:
> * The example has been changed to be independent from local timezone
> * Remove the mention of adding test-cases, since it's obviously necessary.

Will replace Phil's patch with this (hence even under your authorship, the topic name will be reused).

Thanks, both.
Previous: Đoàn Trần Công Danh
Message 12 of 12 in “date.c: allow ISO 8601 reduced precision times”
  1. date.c: allow ISO 8601 reduced precision timesPhil Hord, Dec 16, 2022
  2. Junio C HamanoDec 16, 2022
  3. Phil HordDec 16, 2022
  4. Phil HordJan 9, 2023
  5. Junio C HamanoJan 9, 2023
  6. Junio C HamanoJan 9, 2023
  7. Phil HordJan 9, 2023
  8. fixup! date.c: allow ISO 8601 reduced precision timesĐoàn Trần Công Danh, Jan 9, 2023
  9. date.c: limit less precision ISO-8601 with its markerĐoàn Trần Công Danh, Jan 9, 2023
  10. Phil HordJan 9, 2023
  11. date.c: allow ISO 8601 reduced precision timesĐoàn Trần Công Danh, Jan 11, 2023
  12. Junio C HamanoJan 13, 2023

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.