Pádraig Brady <[email protected]> writes:

> On 04/11/2025 14:17, Pádraig Brady wrote:
>> On 04/11/2025 04:01, Collin Funk wrote:
>>> Many people are used to seeing ISO 8601 dates using a period separating
>>> seconds and nanoseconds. This behavior seems to be worth documenting
>>> given the bug reports:
>>> https://bugs.gnu.org/63119
>>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1118970
>>>
>>> * doc/coreutils.texi (Options for date): Mention that
>>> 'date --iso-8601=ns' uses a comma as a separator, following the
>>> preference of ISO 8601. Give an example of how to get an ISO 8601 date
>>> with a period separator.
>>> ---
>>>    doc/coreutils.texi | 9 +++++++++
>>>    1 file changed, 9 insertions(+)
>>>
>>> diff --git a/doc/coreutils.texi b/doc/coreutils.texi
>>> index 13f9f9a46..a4c9feffc 100644
>>> --- a/doc/coreutils.texi
>>> +++ b/doc/coreutils.texi
>>> @@ -17181,6 +17181,15 @@ @node Options for date
>>>    @item ns
>>>    Also print nanoseconds.
>>>    This is like the format @code{%Y-%m-%dT%H:%M:%S,%N%:z}.
>>> +
>>> +ISO 8601 allows a comma or period to be used to separate seconds from
>>> +subseconds, preferring the use of a comma.  GNU @command{date} follows
>>> +this preference.  If you would prefer to use a period separator, you can
>>> +transform the output of @samp{date --rfc-3339=ns}:
>>> +
>>> +@example
>>> +date --rfc-3339=ns | sed s'/ /T/'
>>> +@end example
>>>    @end table
>>>       @macro dateParseNote
>> I agree this is a bit surprising.
>> I suppose we could use the current locale's decimal_point,
>> falling back to , if the locale's wasn't one of [.,].
>> Though that would introduce varying output when you're asking
>> for a standard format.

That sounds like a good idea to me. But I rather wait until just after a
release. The output has used a comma since it was introduced over 20
years ago [1]. Best to give people time to complain if they dislike the
change, IMO. :)

>> So I suppose post processing is what we're left with:
>> Would the following example be preferable, as it doesn't mix standards,
>> and uses only coreutils commands.
>>     date --iso-8691=ns | tr ' ' T

Yes, that works too. I assume no locale would add a space anywhere in
that date format.

> Actually, maybe setting LC_ALL=C externally is fine,
> in which case you could augment the existing text with:
>
> "Note the preference for a @samp(,} decimal point which you can override
> by expressing the full format with @samp{.} decimal point explicitly,
> like @code{LC_ALL=C date +'%Y-%m-%dT%H:%M:%S.%N%:z'}"

I wanted to mention that the preference was also ISO 8601's. How about
the attached patch that modifies yours slightly?

That should also match the intent of my first patch, without the
confusing mention of another standard.

Collin

[1] 
https://github.com/coreutils/coreutils/commit/11103076722aba896ef11551a25c8e356277da3f

>From 6169d2776242caf8fd1c25b2d2510a88ae3de3e4 Mon Sep 17 00:00:00 2001
Message-ID: <6169d2776242caf8fd1c25b2d2510a88ae3de3e4.1762306199.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Mon, 3 Nov 2025 19:47:52 -0800
Subject: [PATCH v2] doc: mention nanosecond decimal points with --iso-8601=ns

Many people are used to seeing ISO 8601 dates using a period separating
seconds and nanoseconds. This behavior seems to be worth documenting
given the bug reports:
https://bugs.gnu.org/63119
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1118970

* doc/coreutils.texi (Options for date): Mention that
'date --iso-8601=ns' uses a comma as a separator, following the
preference of ISO 8601. Give an example of how to get an ISO 8601 date
with a period separator.
---
 doc/coreutils.texi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 13f9f9a46..06e039d14 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -17181,6 +17181,11 @@ @node Options for date
 @item ns
 Also print nanoseconds.
 This is like the format @code{%Y-%m-%dT%H:%M:%S,%N%:z}.
+
+GNU @command{date} uses a @samp{,} decimal point as prefered by ISO
+8601.  You can override it by expressing the full format with a @samp{.}
+decimal point explicitly, like @code{LC_ALL=C date
++'%Y-%m-%dT%H:%M:%S.%N%:z'}.
 @end table
 
 @macro dateParseNote
-- 
2.51.1

Reply via email to