Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Oct 2021 19:15:10 +0100
From:      Jamie Landeg-Jones <jamie@catflap.org>
To:        freebsd-current@freebsd.org
Subject:   stat(1) isn't honouring locale
Message-ID:  <202110291815.19TIFARt072516@donotpassgo.dyslexicfish.net>

next in thread | raw e-mail | index | archive | help
stat(1) isn't honouring locale.

The manual page says:

     -t timefmt
                  Display timestamps using the specified format.  This format is passed directly to strftime(3).

strftime(3) says:

   %+    is replaced by national representation of the date and time (the format is similar to that produced by date(1)).

However:

-----------------------------
% date
Fri Oct 29 00:14:12 BST 2021

% date +%+
Fri Oct 29 00:14:19 BST 2021

% stat -t%+ -f '%Sm' .
Fri Oct 29 00:13:38 BST 2021
-----------------------------

% setenv LANG en_GB.UTF-8

% date
Fri 29 Oct 2021 00:14:57 BST

% date +%+
Fri 29 Oct 2021 00:15:05 BST

% stat -t%+ -f '%Sm' .
Fri Oct 29 00:13:38 BST 2021
-----------------------------

Including <locale.h> and adding:

(void) setlocale(LC_TIME, "");

before the call to strftime() in usr.bin/stat/stat.c fixes this

Is there any reason this isn't in place?

Cheers, Jamie




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110291815.19TIFARt072516>