Pádraig Brady <[email protected]> writes:
>> Also, I noticed that 'date' uses nl_langinfo (_DATE_FMT). It appears that
>> _DATE_FMT is a glibc extension. Is there any reason that the
>> standardized D_T_FMT isn't used instead?
>> It looks better in my timezone (America/Los_Angeles) at least:
>> $ export LC_ALL=en_US.UTF-8
>> $ ./date-D_T_FMT
>> Sat 11 Oct 2025 10:30:17 PM PDT
>> $ ./date-_DATE_FMT
>> Sat Oct 11 10:30:08 PM PDT 2025
>> With _DATE_FMT the year feels misplaced to me.
>
> That's a question for glibc I think rather than coreutils
Actually, I realize the reason now. POSIX requires the output of 'date'
with no arguments to be the same as the following [1]:
$ date "+%a %b %e %H:%M:%S %Z %Y"
Where "%Z %Y" would be "PDT 2025" in my locale and timezone.
My assumption is some historic implementation of 'date' behaved this
way, so that is what was standardized.
For other programs without this requirement, nl_langinfo (D_T_FMT)
probably works better.
Collin
[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/date.html