coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible ls locale bug


From: Pádraig Brady
Subject: Re: Possible ls locale bug
Date: Tue, 16 Jan 2024 13:32:04 +0000
User-agent: Mozilla Thunderbird

On 15/01/2024 20:42, gnu.3bp3s--- via GNU coreutils General Discussion wrote:
Hello,

My locale is en_IE.UTF-8, so when I run the date command, the output at time of writing 
is "Mon 15 Jan 2024 20:39:04 GMT"

Maybe I'm mistaken, but with that in mind I'd expect the following scenario:
With time locale en_IE.UTF-8 the --time-style=locale within the past year should be equivalent to 
--time-style"+%e %b %R". And older than a year would be equivalent to 
--time-style"+%e %b %Y".

However, this is what I get with following command
$ ls -l --time-style=locale
total 12
drwxr-xr-x 2 bjorn bjorn 4096 Aug 23 2022 dir1
drwxr-xr-x 2 bjorn bjorn 4096 Dec 30 17:44 dir2
drwxr-xr-x 2 bjorn bjorn 4096 Jan 15 19:25 dir3
-rw-r--r-- 1 bjorn bjorn 0 Nov 7 2022 file1
-rw-r--r-- 1 bjorn bjorn 0 Dec 18 12:16 file2
-rw-r--r-- 1 bjorn bjorn 0 Jan 15 19:25 file3

As you can see, even though I specify using my current locale, it outputs date 
as Month before Day.

Is this a locale bug within ls?

Regards,Bjorn N

Well it's not a bug, but it is a bit confusing.
The system locale doesn't define a time/date format that's directly usable by 
ls.
Consider possibilities from the locale for Ireland:

  $ LC_TIME=en_IE.UTF-8 locale -kc LC_TIME | grep 'd.*fmt'
  d_t_fmt="%a %d %b %Y %T"
  d_fmt="%d/%m/%y"
  era_d_fmt=""
  era_d_t_fmt=""
  date_fmt="%a %d %b %Y %T %Z"

Instead ls uses more granular formats,
with the "locale" option being taken from the _translations_ provided for your 
locale.
Since there are generally no English translations provided with coreutils,
--time-style=locale will use the default.
All French locales on the other hand will use a different format, i.e.:

  $ LC_MESSAGES=fr_FR.UTF-8 gettext -d coreutils '%b %e  %Y'
  %e %b  %Y

For related older discussions on this see the thread at:
https://lists.gnu.org/archive/html/bug-coreutils/2009-09/msg00388.html

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]