0

I can't quite make this happen.

Setting LC_TIME seems to work, but the locales are broken or whatever? How do I force this onto my system?

$ for i in (locale -a); bash -c "LC_TIME=$i date -j -f '%Y-%m-%d' '2020-01-05' '+%W %a'" ; end
00 Sun
00 እሑድ
00 нд
00 א'
00 日
…

This should be 01 א' for some of them at least…
What gives?

Looking at /usr/share/locale/* I can't find anything resembling first_weekday keyword at all:

$ cat en_US.UTF-8/LC_TIME 
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
January
February
March
April
May
June
July
August
September
October
November
December
Sun
Mon
Tue
Wed
Thu
Fri
Sat
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
%H:%M:%S
%m/%d/%Y
%a %b %e %X %Y
AM
PM
%a %b %e %X %Z %Y
January
February
March
April
May
June
July
August
September
October
November
December
md
%I:%M:%S %p

macosx 10.12.6 (16G2136)

1
  • The files in /usr/share/locale are generated by localedef out of the source definitions, you won't find keywords in there. – nohillside Nov 10 '20 at 9:27
2

i know this seems like a locale problem -- i spent of bunch of time looking into that but it turns out this is actually a problem with the date command.

from the man page for date:

%U     week number of year, with Sunday as first day of week (00..53)
%W     week number of year, with Monday as first day of week (00..53)

so if i rewrite your command to use %U instead of %W:

for i in $(locale -a); do bash -c "LC_TIME=$i date -j -f '%Y-%m-%d' '2020-01-05' '+%U %a'" ; done

then i am getting all of the results showing week 01 instead of 00. hope this helps!

1
  • This helps. Thanks. – godDLL Nov 29 '20 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .