lc_time and localized dates - Mailing list pgsql-patches

From Euler Taveira de Oliveira
Subject lc_time and localized dates
Date
Msg-id 47C249BE.7090900@timbira.com
Whole thread Raw
Responses Re: lc_time and localized dates
Re: lc_time and localized dates
List 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

pgsql-patches by date:

Previous
From: "Brendan Jurd"
Date:
Subject: Re: Reference by output in : \d
Next
From: "Heikki Linnakangas"
Date:
Subject: Re: Fix for initdb failures on Vista