lc_time and localized dates

From: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: lc_time and localized dates
Date: 2008-02-25 04:53:18
Message-ID: 47C249BE.7090900@timbira.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Hi,

Attached is a patch that replaces the lc_messages with lc_time when
using to_char in translation mode (TM) [1]. It doesn't change the output
behaviour. Per discussion [2], it's using some cache mechanism so we
don't need to call setlocale() all the time.

Some issues:
(i) some locales don't capitalize the first letter. I'm using
pg_toupper() to do the job but I'm afraid it's not appropriated. I'm
using it 'cause i'm too lazy to move localized_str_toupper(). Any
suggestions?
(ii) it didn't address the problem spotted at [3][4]. IMHO, it's ok for
a non-superuser to set lc_time. Opinions?

euler=# show lc_time;
lc_time
---------
pt_BR
(1 registro)

euler=# select to_char(now(), 'TMDay Day dy, DD TMMon Month TMmonth YYYY');
to_char
--------------------------------------------------------
Segunda Monday mon, 25 Fev February fevereiro 2008
(1 registro)

euler=# set lc_time to 'es_ES';
SET
euler=# select to_char(now(), 'TMDay Day dy, DD TMMon Month TMmonth YYYY');
to_char
----------------------------------------------------
Lunes Monday mon, 25 Feb February febrero 2008
(1 registro)

euler=# set lc_time to 'de_DE';
SET
euler=# select to_char(now(), 'TMDay Day dy, DD TMMon Month TMmonth YYYY');
to_char
-----------------------------------------------------
Montag Monday mon, 25 Feb February februar 2008
(1 registro)

euler=# set lc_time to 'fr_FR';
SET
euler=# select to_char(now(), 'TMDay Day dy, DD TMMon Month TMmonth YYYY');
to_char
----------------------------------------------------
Lundi Monday mon, 25 Fév February février 2008
(1 registro)

euler=# set lc_time to 'C';
SET
euler=# select to_char(now(), 'TMDay Day dy, DD TMMon Month TMmonth YYYY');
to_char
------------------------------------------------------
Monday Monday mon, 25 Feb February february 2008
(1 registro)

[1] http://archives.postgresql.org/pgsql-hackers/2006-11/msg00539.php
[2] http://archives.postgresql.org/pgsql-hackers/2006-11/msg00693.php
[3] http://archives.postgresql.org/pgsql-hackers/2007-10/msg00214.php
[4] http://archives.postgresql.org/pgsql-hackers/2006-11/msg00692.php

--
Euler Taveira de Oliveira
http://www.timbira.com/

Attachment Content-Type Size
l10ntochar.diff.gz application/x-gzip 2.7 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message kenneth d'souza 2008-02-25 06:05:31 Reference by output in : \d <table_name>
Previous Message Tatsuhito Kasahara 2008-02-24 11:53:14 Re: Fix pgstatindex using for large indexes