Re: lc_time and localized dates

Bruce Momjian <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.patches
Message-ID <[email protected]>
I have reviewed this patch.  I like the method you used, but I did find
a few things I had to change.

First, I found the abbreviated variable names confusing so I used longer
ones, like:

	extern char       *localized_abbrev_days[7];
	extern char       *localized_full_days[7];
	extern char       *localized_abbrev_months[12];
	extern char       *localized_full_months[12];

Second, I found that the code doing upper/lower case didn't work.  It
was copying the buffer into a 'result' variable, but then incrementing
'result' so by the end 'result' pointed to only the null byte, and that
is the pointer that was returned.  Third, there were a few places where
the code assumed str_toupper() modified the passed buffer, rather than
returning a new one.  And finally, while you used strdup() to save
values in the cache (good), you never free()'ed the old values when you
were reloading the cache.

I have fixed all these items and the updated patch is at:

	ftp://momjian.us/pub/postgresql/mypatches/lc_time

The original patch was here:

	http://archives.postgresql.org/message-id/[email protected]

---------------------------------------------------------------------------

Euler Taveira de Oliveira wrote:
> Bruce Momjian wrote:
> 
> > Euler, have you updated this patch yet?
> > 
> Here is an updated patch. It follows the Oracle behaviour and uses a 
> cache mechanism to avoid calling setlocale() all the time. I unified the 
> localized_* and str_* functions.  I didn't test it on Windows. I would 
> appreciate some feedback.
> 
> 
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
>                to_char
> -----------------------------------
>   thu Qui Quinta apr ABR abril 2008
> (1 registro)
> 
> euler=# set lc_time to 'it_IT.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
>                 to_char
> -------------------------------------
>   thu Gio Gioved? apr APR aprile 2008
> (1 registro)
> 
> euler=# set lc_time to 'es_ES.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
>                to_char
> -----------------------------------
>   thu Jue Jueves apr ABR abril 2008
> (1 registro)
> 
> euler=# set lc_time to 'fr_FR.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
>               to_char
> ----------------------------------
>   thu Jeu Jeudi apr AVR avril 2008
> (1 registro)
> 
> euler=# set lc_time to 'cs_CZ.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
>                to_char
> -----------------------------------
>   thu ?t ?tvrtek apr DUB duben 2008
> (1 registro)
> 
> 
> -- 
>    Euler Taveira de Oliveira
>    http://www.timbira.com/

[ application/x-gzip is not supported, skipping... ]

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

-- 
Sent via pgsql-patches mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.