Re: lc_time and localized dates

From: "Gevik Babakhani" <pgdev(at)xs4all(dot)nl>
To: "'Magnus Hagander'" <magnus(at)hagander(dot)net>
Cc: "'Euler Taveira de Oliveira'" <euler(at)timbira(dot)com>, "'PostgreSQL-patches'" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: lc_time and localized dates
Date: 2008-02-26 12:16:58
Message-ID: 000f01c87871$7f4699b0$0a01a8c0@gevmus
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Magnus,

Please look at this patch before you check my last patch about the locale.
It seems that Euler's solution also fixes the windows locale bug that I was
trying to fix.
Replacing the lc_messages with lc_time when using to_char seems to be the
correct direction.

I have compiled and tested Euler's patch on MSVC and got the correct
results.

Euler,

I think your patch is correct for the most part except you should not force
the first letter of day/month names
to uppercase hence this is not grammatically correct for some languages.

After a quick glimpse of your cache mechanism, I think we can use this to
solve some other TO_CHAR/TO_DATE items.

Regards,
Gevik.

Resuts:
Gevik=# set lc_time to 'Dutch, Netherlands';
SET
Gevik=# select to_char(now() + '8 months'::interval, 'TMDay Day dy, DD TMMon
Month TMmonth YYYY');
to_char
-----------------------------------------------------
Zondag Sunday sun, 26 Okt October oktober 2008
(1 row)

Gevik=#

> -----Original Message-----
> From: pgsql-patches-owner(at)postgresql(dot)org
> [mailto:pgsql-patches-owner(at)postgresql(dot)org] On Behalf Of
> Euler Taveira de Oliveira
> Sent: Monday, February 25, 2008 5:53 AM
> To: PostgreSQL-patches
> Subject: [PATCHES] lc_time and localized dates
>
> 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
ATT00068.txt text/plain 135 bytes

Browse pgsql-patches by date

  From Date Subject
Next Message mac_man2005 2008-02-26 13:15:00 Re: [HACKERS] 2WRS [WIP]
Previous Message Gevik Babakhani 2008-02-26 09:53:18 Re: lc_time and localized dates