Reputation: 2291
I was wondering if I could make visible the chosen locale. I do (on windows),
>bin\initdb --locale=en-us --encoding=utf-8 -U postgres -W clus1
>bin\pg_ctl.exe -D clus1 -l logfile2 start
>psql -U postgres
postgres=# select now();
now
-------------------------------
2022-03-07 21:15:07.56299+01
>bin\pg_ctl.exe -D clus1 -l logfile2 stop
>rmdir /s clus1
Now I choose another locale,
>bin\initdb --locale=nl-nl --encoding=utf-8 -U postgres -W clus1
>bin\pg_ctl.exe -D clus1 -l logfile2 start
>psql -U postgres
postgres=# select now();
now
-------------------------------
2022-03-07 21:16:30.071371+01
I thought now() would be in Dutch, but is isn't. Why not, and how can I make the locale visible, so check the chosen locale?
Upvotes: 0
Views: 1858
Reputation: 246503
The locale consists of several parts:
lc_collate
: the rules to compare and sort strings
lc_ctype
: the rules to determine what type a character is (letter, digit, space, ...)
lc_messages
: the language for error and log messages
lc_monetary
: the language to use for currency format codes in to_char
for numbers
To see the effect of lc_monetary
, try
SELECT to_char(100, '999L');
lc_numeric
: the language to use for decimal comma and group separator format codes in to_char
for numbers
To see the effect of lc_numeric
, try
SELECT to_char(1000000.50, '9G999G999D00L');
lc_time
: the language to use for week day and month name format codes in to_char
for timestamps, log_filename
and such
To see the effect of lc_numeric
, try
SELECT to_char(current_timestamp, 'FMDAY, DD. FMMONTH');
You can find the setting of each of them with SHOW
:
SHOW lc_collate;
The type output functions for date/time and numeric data types don't use the locale settings, so the output of now()
not affected by the locale.
Upvotes: 2