From 20f8331aca892ff812510609b3bc4e747b201197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Sat, 30 Oct 2021 09:00:34 +0200 Subject: [PATCH] usr.bin/stat: honour locale for "-t %+" The man page states that "-t %+" prints time information in the same format as date with no format specifier. This was not the case, the format used was always that of date for the POSIX locale. The fix suggested by the reporter leads to output that matches the documentation. Reported by: Jamie Landeg-Jones MFC after: 3 days --- usr.bin/stat/stat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.bin/stat/stat.c b/usr.bin/stat/stat.c index e504333c332..9d94399a633 100644 --- a/usr.bin/stat/stat.c +++ b/usr.bin/stat/stat.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -763,6 +764,7 @@ format1(const struct stat *st, ts.tv_sec = 0; tm = localtime(&ts.tv_sec); } + (void)setlocale(LC_TIME, ""); (void)strftime(path, sizeof(path), timefmt, tm); sdata = path; formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |