In a recent question I asked what's the best practice for this kind of change. There was no answer yet. However, I can give you the recipe I am using, which has proven to work fine. All the programs pick the date up correctly.
My description is for Ubuntu, but will likely work on Debian and Mint.
Preparations
Copy the locale you want to customize from /usr/share/i18n/locales
to a new file. E.g.
cp /usr/share/i18n/locales/de_DE /usr/share/i18n/locales/de_DE@isodate
Adjust all with the exception of the LC_TIME
sections to:
copy "de_DE"
Adjust the LC_TIME
section to match your desired outcome. You can use the settings from my above linked question as a template. It looks like this is pretty much exactly what you want.
If your locale doesn't make use of "AM/PM" notation, set those to empty:
t_fmt_ampm ""
am_pm "";""
Making it known to the system
Edit the file /var/lib/locales/supported.d/local
and add the info about your locale definition there. I.e. add a line like this if your file name above was isodate
, adjust otherwise:
de_DE.UTF-8@isodate UTF-8
If /var/lib/locales/supported.d/local
doesn't exist, create a file of that name. Don't put your changes into the respective en
or de
file in that folder, as they may get overwritten as soon as the language-pack-*-base
and language-pack-*
packages on your system receive an update.
Now run dpkg-reconfigure locales
:
# dpkg-reconfigure locales
Generating locales...
de_DE.UTF-8@isodate... done
de_DE.UTF-8... up-to-date
Generation complete.
In your case this will indicate that the de_DE.UTF-8@isodate
locale has been generated (assuming you have no syntax issues).
Last but not least add the following to /etc/default/locale
:
LC_TIME="de_DE.UTF-8@isodate"
This will ensure that only LC_TIME
overrides the default locale defined using LANG
.
Log in anew and you should be able to see the new ISO date/time when using date
or other tools using the respective libc runtime function.
The intent here is to make the least intrusive change while also not working against the system (e.g. against package manager and friends). Of course you can also simply create a copy of your locale, install it in a similar fashion as outlined above and then adjust LANG
. The point is, as long as you don't want to run the risk of your changes being overwritten by a package update, you have to use a customized copy (whatever customization you go for; i.e. copy
or simply keep the sections as they were in the original). And whether you change LANG
to point to the full customized locale definition - or whether you add LC_TIME
to point only to the relevant customized section of the same name of a customized locale definition file - you won't get around adjusting one of the global settings.
en_XX
-- I don't know what the restrictions here are, trial and error might suffice), make whatever changes you want to that, and use it as the locale. You'll have to regenerate the list or whatever afterward, etc.LC_TIME
(in/etc/environment
or/etc/default/locale
or/etc/locale.conf
depending on distro) to the modified locale (I called mineisodate.UTF-8
) and the respective format will get picked from that customized locale for only time/date. This is how I customized my otherwiseen_US
setting to display ISO date/time./var/lib/locales/supported.d/local
(or one of the other files in there) and rundpkg-reconfigure locales
as superuser for the locale definition to be compiled. And yes, settingLC_TIME
to point to a customized locale appears to be the least intrusive method of all I've seen so far. That's why your system has global settings whereLC_TIME
can be set different from the "overall locale".copy
on sections approach, or keep other sections redundant (so that I candiff
against the original file).