Fiddling with locale so that weeks start on Monday

I use the C.UTF-8 locale and all is well, I’m pretty happy with it but weeks starting on Sunday…
Is there a single or combination locale setting that changes only the first day of the week, leaving the names of days and months in English?

I simply want that locale first_weekday to return 2. No particular concern for any application. locale, as far as I know, is regulated by POSIX (I’d be happy to be corrected) so, at least for now, I don’t see a particular motivation for detailing my system any more.

EDIT

Following a comment from St├ęphane Chazelas I’d like to inform you that I’m using Debian Sid.

Asked By: gboffi

||

There are at least three options:

  1. create a new locale from C.UTF-8 and just change that first_weekday value. Let’s call it X.UTF-8. In Debian, this should do it, if you have permissions on those directories:
    cp -R /usr/lib/locale/C.UTF-8 /usr/lib/locale/X.UTF-8
    cat /usr/share/i18n/locales/C | sed -E 's/first_weekday[[:blank:]]+1/first_weekday 2/g' | localedef --add-to-archive /usr/lib/locale/X.UTF-8 -i -
    LC_TIME=X.UTF-8 locale first_weekday

So you copy the existing definition, just a lazy way to recreate the folder structure, then from the original C.UTF-8 (the name is just "C") you change the line that refers to the first weekday (it could be shorter, with a positional parameter, but I find it’s more readable like this).

  1. modify that value in your existing C.UTF-8 locale:
    cat /usr/share/i18n/locales/C | sed -E 's/first_weekday[[:blank:]]+1/first_weekday 2/g' | localedef --add-to-archive /usr/lib/locale/C.UTF-8 -i -
    LC_TIME=C.UTF-8 locale first_weekday
  1. Well, if you are ok with the other differences between en_GB and C.UTF-8, then these steps should do the change:

Depending on your system, not all locales are available right away. So first, make sure you have en_GB.UTF-8 available (or you will get the error "Cannot set LC_ALL to default locale"):

locale -a

if you don’t, then add it. Since there is no info on your system I cannot tell you how to do it. In Debian/Ubuntu you can do dpkg-reconfigure locales (or edit /etc/locale.gen to add the locale or, most likely, just uncomment it, and then run locale-gen).

Once en_GB.UTF-8 is in the list of available locales, you can then set:

LC_TIME=en_GB.UTF-8

LC_TIME=en_GB.UTF-8 locale first_weekday

should return 2

This Debian document has more info on how to make the change permanent for different environments.

Answered By: Eduardo Trápani
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.