2

I want to set a custom time format or the time format specific to my localisation but I want to keep the names of days and months in English. How can I set it to something like YYYY-MM-DD, Monday, 20:05:47 CET?

There are multiple similar questions, e.g. How to change time and date language to English? and Combine English language and alternative locale

None of them are the solution - $LC_TIME bounds format to language and I want to know if there's a different way of handling formats in Linux, some kind of alternative to locale that'd allow to specify the time format and the language separately. Creating a custom locale is of course possible but it confuses most applications. Did anyone came out with anything better over all these years?

cprn
  • 1,209

2 Answers2

2

Hmm... this is not a direct answer, but something that might give a clear hint what to try:

$ sudo -i
...
# cp sv_SE_nerdy /usr/share/i18n/locales/
# echo "sv_SE_nerdy UTF-8" >> /etc/locale.gen
# locale-gen
# exit # sudo
$ localectl set-locale LC_MONETARY=sv_SE_nerdy
$ localectl set-locale LC_NUMERIC=sv_SE_nerdy
$ echo >>.bash_aliases "export LC_MONETARY=sv_SE_nerdy"
$ echo >>.bash_aliases "export LC_NUMERIC=sv_SE_nerdy"
$ localectl status
   System Locale: LANG=status
                  LC_NUMERIC=sv_SE_nerdy
                  LC_TIME=sv_SE.UTF-8
                  LC_MONETARY=sv_SE_nerdy
                  LC_PAPER=sv_SE.UTF-8
                  LC_NAME=sv_SE.UTF-8
                  LC_ADDRESS=sv_SE.UTF-8
                  LC_TELEPHONE=sv_SE.UTF-8
                  LC_MEASUREMENT=sv_SE.UTF-8
                  LC_IDENTIFICATION=sv_SE.UTF-8
       VC Keymap: sv-latin1
      X11 Layout: se
       X11 Model: asus_laptop
     X11 Options: terminate:ctrl_alt_bksp

and what I changed in sv_SE to create the ..._nerdy version:

$ cat sv_SE_diff 
--- /usr/share/i18n/locales/sv_SE   2022-04-07 03:24:41.000000000 +0200
+++ sv_SE_nerdy 2022-10-31 09:51:36.262570560 +0100
@@ -34 +34 @@
-title      "Swedish locale for Sweden"
+title      "Swedish locale for Sweden, decimal point in numbers and monetary values, narrow space number grouping"
@@ -41 +41 @@
-language   "Swedish"
+language   "Swedish, w DP"
@@ -44 +44 @@
-date       "2000-06-29"
+date       "2022-10-31"
@@ -182,2 +182,2 @@
-mon_decimal_point       ","
-mon_thousands_sep       "<U202F>"
+mon_decimal_point       "."
+mon_thousands_sep       "<U200A>"
@@ -198,2 +198,2 @@
-decimal_point           ","
-thousands_sep           "<U202F>"
+decimal_point           "."
+thousands_sep           "<U200A>"
@@ -276 +276 @@
-lang_name    "svenska"
+lang_name    "svenska, decimalpunkt"

... U200A defines unicode character 200A,
click on a char in character map to see the code for the selected character.
Display the character encoded (by a code) by typing e.g.CTRL+u followed by 202F+Enter in e.g. gnome-shell / Terminal.

and one more thing: the sv_SE locale formats dates as:

$ date 
sön  8 jan 2023 21:34:58 CET

... which may give a good hint on what to change the date format to.

Hannu
  • 6,605
  • 1
  • 28
  • 45
0

Open your ~/.profile file for editing and add this line:

export LC_TIME=en_DK.UTF-8

While that is not exactly "specific to your localization" (unless you happen to be Danish), it gives you days and months in English and a sensible date/time format.