{"thread":{"id":"61110","subject":"log.date 'iso-strict' does not comply with ISO 8601-1:2020-12","startedAt":"2024-03-13T11:37:56Z","lastAt":"2024-03-13T23:06:39Z","messageCount":10,"participants":["Osipov, Michael (IN IT IN)","Beat Bolli","Junio C Hamano","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"490537","messageId":"410d458c-ae5b-40cc-9c8e-97b016c74a76@siemens.com","threadId":"61110","inReplyTo":null,"subject":"log.date 'iso-strict' does not comply with ISO 8601-1:2020-12","fromName":"Osipov, Michael (IN IT IN)","fromEmail":"michael.osipov@innomotics.com","sentAt":"2024-03-13T11:27:37Z","receivedAt":"2024-03-13T11:37:56Z","isPatch":false,"sender":{"key":"michael.osipov@innomotics.com","avatar":null},"body":"Folks,\n\nI am running git version 2.43.0 and consider the following config:\n> $ git config --system --list\n> core.eol=native\n> log.date=iso-strict\n> color.ui=auto\n\nwhen a commit happens with a zero offset the following is displayed:\n> osipovmi@deblndw011x:~/var/Projekte/tomcat-native ((ba1454e15...)|BISECTING)\n> $ git log\n> commit ba1454e15619a44fe66d86f59c766c0cc25323eb (HEAD)\n> Author: Mark Thomas <markt@apache.org>\n> Date:   2024-02-13T08:27:43+00:00\n> \n>     Fix link\n> \n\nThis not right according to the standard in the original language \nversion, namely in sections:\n* 4.3.13 Zeitverschiebung (time shift) (roughly translated from German): \nZ denotes that there is no shift from UTC. It also says that you either \nhave an offset or use \"Z\"\n* 5.3.3 Uhrzeit in UTC (time in UTC) (roughly translated from German): \n...the formats from sections ... must be used followed by the UTC marker \n\"Z\" without space.\n\nThroughout the definition neither +0000 for the basic format nor +00:00 \nfor the extended format are used to denote a zero offset from UTC.\n\nThe offending code snippet is here: \nhttps://github.com/git/git/blob/945115026aa63df4ab849ab14a04da31623abece/date.c#L344-L352\n\nSee also Java's Instant class [1] which is based on ISO 8601 as well is \nJava's SimpleDateFormat XXX [2] which will *always* print \"Z\" in case of \na zero offset.\n\nI'd expect Git to comply with strict since this is why it has been \nintroduced years ago instead of modifying 'iso'.\n\nRegards,\n\nMichael\n\n[1] https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html\n[2] \nhttps://github.com/openjdk/jdk8u-dev/blob/fbb3392d744d1572239eeca082d7365a03897b8b/jdk/src/share/classes/java/text/SimpleDateFormat.java#L1291-L1306\n"},{"id":"490561","messageId":"20240313175000.2148-1-dev+git@drbeat.li","threadId":"61110","inReplyTo":"410d458c-ae5b-40cc-9c8e-97b016c74a76@siemens.com","subject":"[PATCH] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Beat Bolli","fromEmail":"bb@drbeat.li","sentAt":"2024-03-13T17:50:00Z","receivedAt":"2024-03-13T17:50:18Z","isPatch":true,"sender":{"key":"bb@drbeat.li","avatar":null},"body":"ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\nwith a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\nspecial case to show_date() and a new test.\n\nReported-by: Michael Osipov <michael.osipov@innomotics.com>\nLink: https://lore.kernel.org/git/410d458c-ae5b-40cc-9c8e-97b016c74a76@siemens.com/\nSigned-off-by: Beat Bolli <dev+git@drbeat.li>\n---\n date.c          | 14 +++++++++-----\n t/t0006-date.sh |  1 +\n 2 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/date.c b/date.c\nindex 619ada5b2044..44cf2221d81f 100644\n--- a/date.c\n+++ b/date.c\n@@ -342,14 +342,18 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)\n \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n \t\t\t\ttz);\n \telse if (mode->type == DATE_ISO8601_STRICT) {\n-\t\tchar sign = (tz >= 0) ? '+' : '-';\n-\t\ttz = abs(tz);\n-\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d\",\n+\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d\",\n \t\t\t\ttm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1,\n \t\t\t\ttm->tm_mday,\n-\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n-\t\t\t\tsign, tz / 100, tz % 100);\n+\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec);\n+\t\tif (tz == 0) {\n+\t\t\tstrbuf_addch(&timebuf, 'Z');\n+\t\t} else {\n+\t\t\tstrbuf_addch(&timebuf, tz >= 0 ? '+' : '-');\n+\t\t\ttz = abs(tz);\n+\t\t\tstrbuf_addf(&timebuf, \"%02d:%02d\", tz / 100, tz % 100);\n+\t\t}\n \t} else if (mode->type == DATE_RFC2822)\n \t\tstrbuf_addf(&timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n \t\t\tweekday_names[tm->tm_wday], tm->tm_mday,\ndiff --git a/t/t0006-date.sh b/t/t0006-date.sh\nindex e18b1602864e..1d228a981ee9 100755\n--- a/t/t0006-date.sh\n+++ b/t/t0006-date.sh\n@@ -46,6 +46,7 @@ check_show () {\n TIME='1466000000 +0200'\n check_show iso8601 \"$TIME\" '2016-06-15 16:13:20 +0200'\n check_show iso8601-strict \"$TIME\" '2016-06-15T16:13:20+02:00'\n+check_show iso8601-strict \"$(echo \"$TIME\" | sed 's/+0200$/+0000/')\" '2016-06-15T14:13:20Z'\n check_show rfc2822 \"$TIME\" 'Wed, 15 Jun 2016 16:13:20 +0200'\n check_show short \"$TIME\" '2016-06-15'\n check_show default \"$TIME\" 'Wed Jun 15 16:13:20 2016 +0200'\n-- \n2.44.0\n\n"},{"id":"490569","messageId":"xmqqwmq6asrx.fsf@gitster.g","threadId":"61110","inReplyTo":"20240313175000.2148-1-dev+git@drbeat.li","subject":"Re: [PATCH] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-13T18:30:42Z","receivedAt":"2024-03-13T18:30:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Beat Bolli\" <bb@drbeat.li> writes:\n\n> ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\n> with a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\n> special case to show_date() and a new test.\n\nHmph, would this break existing scripts that expects the current\nbehaviour, and if it does, is it safe for us to blame the script\nauthors for not following the standard?\n\nAssuming that we do not need to worry about them, the patch itself\nlooks perfectly reasonable to me.\n\nThanks.\n\n> Reported-by: Michael Osipov <michael.osipov@innomotics.com>\n> Link: https://lore.kernel.org/git/410d458c-ae5b-40cc-9c8e-97b016c74a76@siemens.com/\n> Signed-off-by: Beat Bolli <dev+git@drbeat.li>\n> ---\n>  date.c          | 14 +++++++++-----\n>  t/t0006-date.sh |  1 +\n>  2 files changed, 10 insertions(+), 5 deletions(-)\n>\n> diff --git a/date.c b/date.c\n> index 619ada5b2044..44cf2221d81f 100644\n> --- a/date.c\n> +++ b/date.c\n> @@ -342,14 +342,18 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)\n>  \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n>  \t\t\t\ttz);\n>  \telse if (mode->type == DATE_ISO8601_STRICT) {\n> -\t\tchar sign = (tz >= 0) ? '+' : '-';\n> -\t\ttz = abs(tz);\n> -\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d\",\n> +\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d\",\n>  \t\t\t\ttm->tm_year + 1900,\n>  \t\t\t\ttm->tm_mon + 1,\n>  \t\t\t\ttm->tm_mday,\n> -\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n> -\t\t\t\tsign, tz / 100, tz % 100);\n> +\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec);\n> +\t\tif (tz == 0) {\n> +\t\t\tstrbuf_addch(&timebuf, 'Z');\n> +\t\t} else {\n> +\t\t\tstrbuf_addch(&timebuf, tz >= 0 ? '+' : '-');\n> +\t\t\ttz = abs(tz);\n> +\t\t\tstrbuf_addf(&timebuf, \"%02d:%02d\", tz / 100, tz % 100);\n> +\t\t}\n>  \t} else if (mode->type == DATE_RFC2822)\n>  \t\tstrbuf_addf(&timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n>  \t\t\tweekday_names[tm->tm_wday], tm->tm_mday,\n> diff --git a/t/t0006-date.sh b/t/t0006-date.sh\n> index e18b1602864e..1d228a981ee9 100755\n> --- a/t/t0006-date.sh\n> +++ b/t/t0006-date.sh\n> @@ -46,6 +46,7 @@ check_show () {\n>  TIME='1466000000 +0200'\n>  check_show iso8601 \"$TIME\" '2016-06-15 16:13:20 +0200'\n>  check_show iso8601-strict \"$TIME\" '2016-06-15T16:13:20+02:00'\n> +check_show iso8601-strict \"$(echo \"$TIME\" | sed 's/+0200$/+0000/')\" '2016-06-15T14:13:20Z'\n>  check_show rfc2822 \"$TIME\" 'Wed, 15 Jun 2016 16:13:20 +0200'\n>  check_show short \"$TIME\" '2016-06-15'\n>  check_show default \"$TIME\" 'Wed Jun 15 16:13:20 2016 +0200'\n"},{"id":"490574","messageId":"f2fff194-5df4-4bb6-9044-7d7bba529570@siemens.com","threadId":"61110","inReplyTo":"20240313175000.2148-1-dev+git@drbeat.li","subject":"Re: [PATCH] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Osipov, Michael (IN IT IN)","fromEmail":"michael.osipov@innomotics.com","sentAt":"2024-03-13T19:27:43Z","receivedAt":"2024-03-13T19:27:52Z","isPatch":true,"sender":{"key":"michael.osipov@innomotics.com","avatar":null},"body":"On 2024-03-13 18:50, Beat Bolli wrote:\n> ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\n> with a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\n> special case to show_date() and a new test.\n\nThanks for this lightspeed fix!\n"},{"id":"490575","messageId":"fa133642-e9b0-4443-b21c-c864c9e4f9b6@siemens.com","threadId":"61110","inReplyTo":"xmqqwmq6asrx.fsf@gitster.g","subject":"Re: [PATCH] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Osipov, Michael (IN IT IN)","fromEmail":"michael.osipov@innomotics.com","sentAt":"2024-03-13T19:29:49Z","receivedAt":"2024-03-13T19:29:54Z","isPatch":true,"sender":{"key":"michael.osipov@innomotics.com","avatar":null},"body":"On 2024-03-13 19:30, Junio C Hamano wrote:\n> \"Beat Bolli\" <bb@drbeat.li> writes:\n> \n>> ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\n>> with a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\n>> special case to show_date() and a new test.\n> \n> Hmph, would this break existing scripts that expects the current\n> behaviour, and if it does, is it safe for us to blame the script\n> authors for not following the standard?\n\n From my PoV, if they don't stick it is not you to blame. The standard \nalso says that it is equiv (\"Z\") to both numeral offsets. At the end \nstrict is strict.\n\nThanks,\n\nMichael\n"},{"id":"490576","messageId":"63cb03c6-fc2c-4fab-8aef-caba19adbb8d@app.fastmail.com","threadId":"61110","inReplyTo":"20240313175000.2148-1-dev+git@drbeat.li","subject":"Re: [PATCH] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2024-03-13T20:09:43Z","receivedAt":"2024-03-13T20:10:06Z","isPatch":true,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"On Wed, Mar 13, 2024, at 18:50, Beat Bolli wrote:\n> Reported-by: Michael Osipov <michael.osipov@innomotics.com>\n> Link: https://lore.kernel.org/git/410d458c-ae5b-40cc-9c8e-97b016c74a76@siemens.com/\n> Signed-off-by: Beat Bolli <dev+git@drbeat.li>\n\nI personally don’t really think `Link` trailers are necessary in this\nproject given the existence of `refs/notes/amlog`.\n\n🔗 https://lore.kernel.org/git/ebe188e5-7289-4f7b-b845-d59a47cd06fe@app.fastmail.com/\n\n-- \nKristoffer Haugsbakk\n\n"},{"id":"490588","messageId":"20240313222922.11170-1-dev+git@drbeat.li","threadId":"61110","inReplyTo":"xmqqwmq6asrx.fsf@gitster.g","subject":"[PATCH v2] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Beat Bolli","fromEmail":"bb@drbeat.li","sentAt":"2024-03-13T22:29:22Z","receivedAt":"2024-03-13T22:29:45Z","isPatch":true,"sender":{"key":"bb@drbeat.li","avatar":null},"body":"ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\nwith a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\nspecial case to show_date() and a new test.\n\nThis changes an established output format which might be depended on by\nscripts. The original patch 466fb6742d7f (pretty: provide a strict ISO\n8601 date format, 2014-08-29) mentioned XML parsers as its rationale,\nwhich generally have good parsing support, so this change should be\nfine.\n\nReported-by: Michael Osipov <michael.osipov@innomotics.com>\nSigned-off-by: Beat Bolli <dev+git@drbeat.li>\n---\nChanges from v1:\n\n- added a comment why the change is fine\n- removed the Link: trailer\n\n date.c          | 14 +++++++++-----\n t/t0006-date.sh |  1 +\n 2 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/date.c b/date.c\nindex 619ada5b2044..44cf2221d81f 100644\n--- a/date.c\n+++ b/date.c\n@@ -342,14 +342,18 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)\n \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n \t\t\t\ttz);\n \telse if (mode->type == DATE_ISO8601_STRICT) {\n-\t\tchar sign = (tz >= 0) ? '+' : '-';\n-\t\ttz = abs(tz);\n-\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d\",\n+\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d\",\n \t\t\t\ttm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1,\n \t\t\t\ttm->tm_mday,\n-\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n-\t\t\t\tsign, tz / 100, tz % 100);\n+\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec);\n+\t\tif (tz == 0) {\n+\t\t\tstrbuf_addch(&timebuf, 'Z');\n+\t\t} else {\n+\t\t\tstrbuf_addch(&timebuf, tz >= 0 ? '+' : '-');\n+\t\t\ttz = abs(tz);\n+\t\t\tstrbuf_addf(&timebuf, \"%02d:%02d\", tz / 100, tz % 100);\n+\t\t}\n \t} else if (mode->type == DATE_RFC2822)\n \t\tstrbuf_addf(&timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n \t\t\tweekday_names[tm->tm_wday], tm->tm_mday,\ndiff --git a/t/t0006-date.sh b/t/t0006-date.sh\nindex e18b1602864e..1d228a981ee9 100755\n--- a/t/t0006-date.sh\n+++ b/t/t0006-date.sh\n@@ -46,6 +46,7 @@ check_show () {\n TIME='1466000000 +0200'\n check_show iso8601 \"$TIME\" '2016-06-15 16:13:20 +0200'\n check_show iso8601-strict \"$TIME\" '2016-06-15T16:13:20+02:00'\n+check_show iso8601-strict \"$(echo \"$TIME\" | sed 's/+0200$/+0000/')\" '2016-06-15T14:13:20Z'\n check_show rfc2822 \"$TIME\" 'Wed, 15 Jun 2016 16:13:20 +0200'\n check_show short \"$TIME\" '2016-06-15'\n check_show default \"$TIME\" 'Wed Jun 15 16:13:20 2016 +0200'\n-- \n2.44.0\n\n"},{"id":"490590","messageId":"xmqqmsr169e5.fsf@gitster.g","threadId":"61110","inReplyTo":"20240313222922.11170-1-dev+git@drbeat.li","subject":"Re: [PATCH v2] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-13T22:42:58Z","receivedAt":"2024-03-13T22:43:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Beat Bolli\" <bb@drbeat.li> writes:\n\n> ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\n> with a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\n> special case to show_date() and a new test.\n>\n> This changes an established output format which might be depended on by\n> scripts. The original patch 466fb6742d7f (pretty: provide a strict ISO\n> 8601 date format, 2014-08-29) mentioned XML parsers as its rationale,\n> which generally have good parsing support, so this change should be\n> fine.\n\n\"fine.\" -> \"fine for that particular usecase.\"\n\nUnlike in 2005, we no longer write our features only for our own\nsingle use case that motivated it.  I do not think it is possible\nto make this change without breaking some real script, and admitting\nthis is a breaking change and we are knowingly doing so is probably\nbetter in the longer term.\n\nSaying \"this should be fine\" in the log will give future developers\nroom to consider reverting it, and while they are free to make such\na decision based on the reality at their time in the future, we\nshould give them a data point from our point of view: we know it may\nbreak somebody but we are still doing so knowingly as upside to\nadhere to a published standard and help those users who adhere to\nthe same standard is more valuable then the unfortunate script that\nbended themselves to match our earlier mistake.\n\nThanks.\n"},{"id":"490592","messageId":"20240313225423.11373-1-dev+git@drbeat.li","threadId":"61110","inReplyTo":"xmqqmsr169e5.fsf@gitster.g","subject":"[PATCH v3] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Beat Bolli","fromEmail":"bb@drbeat.li","sentAt":"2024-03-13T22:54:23Z","receivedAt":"2024-03-13T22:54:35Z","isPatch":true,"sender":{"key":"bb@drbeat.li","avatar":null},"body":"ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\nwith a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\nspecial case to show_date() and a new test.\n\nChanging an established output format which might be depended on by\nscripts is always problematic, but here we choose to adhere more closely\nto the published standard.\n\nReported-by: Michael Osipov <michael.osipov@innomotics.com>\nSigned-off-by: Beat Bolli <dev+git@drbeat.li>\n---\nChanges from v2:\n\n- changed the rationale according to Junio's feedback\n\nChanges from v1:\n\n- added a comment why the change is fine\n- removed the Link: trailer\n\n date.c          | 14 +++++++++-----\n t/t0006-date.sh |  1 +\n 2 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/date.c b/date.c\nindex 619ada5b2044..44cf2221d81f 100644\n--- a/date.c\n+++ b/date.c\n@@ -342,14 +342,18 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)\n \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n \t\t\t\ttz);\n \telse if (mode->type == DATE_ISO8601_STRICT) {\n-\t\tchar sign = (tz >= 0) ? '+' : '-';\n-\t\ttz = abs(tz);\n-\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d\",\n+\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d\",\n \t\t\t\ttm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1,\n \t\t\t\ttm->tm_mday,\n-\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n-\t\t\t\tsign, tz / 100, tz % 100);\n+\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec);\n+\t\tif (tz == 0) {\n+\t\t\tstrbuf_addch(&timebuf, 'Z');\n+\t\t} else {\n+\t\t\tstrbuf_addch(&timebuf, tz >= 0 ? '+' : '-');\n+\t\t\ttz = abs(tz);\n+\t\t\tstrbuf_addf(&timebuf, \"%02d:%02d\", tz / 100, tz % 100);\n+\t\t}\n \t} else if (mode->type == DATE_RFC2822)\n \t\tstrbuf_addf(&timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n \t\t\tweekday_names[tm->tm_wday], tm->tm_mday,\ndiff --git a/t/t0006-date.sh b/t/t0006-date.sh\nindex e18b1602864e..1d228a981ee9 100755\n--- a/t/t0006-date.sh\n+++ b/t/t0006-date.sh\n@@ -46,6 +46,7 @@ check_show () {\n TIME='1466000000 +0200'\n check_show iso8601 \"$TIME\" '2016-06-15 16:13:20 +0200'\n check_show iso8601-strict \"$TIME\" '2016-06-15T16:13:20+02:00'\n+check_show iso8601-strict \"$(echo \"$TIME\" | sed 's/+0200$/+0000/')\" '2016-06-15T14:13:20Z'\n check_show rfc2822 \"$TIME\" 'Wed, 15 Jun 2016 16:13:20 +0200'\n check_show short \"$TIME\" '2016-06-15'\n check_show default \"$TIME\" 'Wed Jun 15 16:13:20 2016 +0200'\n-- \n2.44.0\n\n"},{"id":"490594","messageId":"xmqq5xxp68au.fsf@gitster.g","threadId":"61110","inReplyTo":"20240313225423.11373-1-dev+git@drbeat.li","subject":"Re: [PATCH v3] date: make \"iso-strict\" conforming for the UTC timezone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-13T23:06:33Z","receivedAt":"2024-03-13T23:06:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Beat Bolli\" <bb@drbeat.li> writes:\n\n> ISO 8601-1:2020-12 specifies that a zero timezone offset must be denoted\n> with a \"Z\" suffix instead of the numeric \"+00:00\". Add the correponding\n> special case to show_date() and a new test.\n>\n> Changing an established output format which might be depended on by\n> scripts is always problematic, but here we choose to adhere more closely\n> to the published standard.\n\nPerfect.  Thanks for following it through.  Will replace (I've\nqueued v2 already but it is easy to replace).\n\n>\n> Reported-by: Michael Osipov <michael.osipov@innomotics.com>\n> Signed-off-by: Beat Bolli <dev+git@drbeat.li>\n> ---\n> Changes from v2:\n>\n> - changed the rationale according to Junio's feedback\n>\n> Changes from v1:\n>\n> - added a comment why the change is fine\n> - removed the Link: trailer\n>\n>  date.c          | 14 +++++++++-----\n>  t/t0006-date.sh |  1 +\n>  2 files changed, 10 insertions(+), 5 deletions(-)\n>\n> diff --git a/date.c b/date.c\n> index 619ada5b2044..44cf2221d81f 100644\n> --- a/date.c\n> +++ b/date.c\n> @@ -342,14 +342,18 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)\n>  \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n>  \t\t\t\ttz);\n>  \telse if (mode->type == DATE_ISO8601_STRICT) {\n> -\t\tchar sign = (tz >= 0) ? '+' : '-';\n> -\t\ttz = abs(tz);\n> -\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d\",\n> +\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02dT%02d:%02d:%02d\",\n>  \t\t\t\ttm->tm_year + 1900,\n>  \t\t\t\ttm->tm_mon + 1,\n>  \t\t\t\ttm->tm_mday,\n> -\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n> -\t\t\t\tsign, tz / 100, tz % 100);\n> +\t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec);\n> +\t\tif (tz == 0) {\n> +\t\t\tstrbuf_addch(&timebuf, 'Z');\n> +\t\t} else {\n> +\t\t\tstrbuf_addch(&timebuf, tz >= 0 ? '+' : '-');\n> +\t\t\ttz = abs(tz);\n> +\t\t\tstrbuf_addf(&timebuf, \"%02d:%02d\", tz / 100, tz % 100);\n> +\t\t}\n>  \t} else if (mode->type == DATE_RFC2822)\n>  \t\tstrbuf_addf(&timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n>  \t\t\tweekday_names[tm->tm_wday], tm->tm_mday,\n> diff --git a/t/t0006-date.sh b/t/t0006-date.sh\n> index e18b1602864e..1d228a981ee9 100755\n> --- a/t/t0006-date.sh\n> +++ b/t/t0006-date.sh\n> @@ -46,6 +46,7 @@ check_show () {\n>  TIME='1466000000 +0200'\n>  check_show iso8601 \"$TIME\" '2016-06-15 16:13:20 +0200'\n>  check_show iso8601-strict \"$TIME\" '2016-06-15T16:13:20+02:00'\n> +check_show iso8601-strict \"$(echo \"$TIME\" | sed 's/+0200$/+0000/')\" '2016-06-15T14:13:20Z'\n>  check_show rfc2822 \"$TIME\" 'Wed, 15 Jun 2016 16:13:20 +0200'\n>  check_show short \"$TIME\" '2016-06-15'\n>  check_show default \"$TIME\" 'Wed Jun 15 16:13:20 2016 +0200'\n"}]}