Re: TODO item:Allow to_date() and to_timestamp() accept localized month names - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: TODO item:Allow to_date() and to_timestamp() accept localized month names
Date
Msg-id 200802081556.m18FuiH24782@momjian.us
Whole thread Raw
In response to Re: TODO item:Allow to_date() and to_timestamp() accept localized month names  ("Gevik Babakhani" <pgdev@xs4all.nl>)
Responses Re: TODO item:Allow to_date() and to_timestamp() accept localized month names
List pgsql-hackers
Gevik Babakhani wrote:
> > 
> > Surely it should be the inverse of the solution for output, 
> > eg TMMon selects localized input.
> > 
> 
> After some investigation in how gettext works, I would like to have your
> opinion about how to 
> implement this TODO item.
> 
> Starting with TO_CHAR: 
> 
> When the TM prefix is used in TO_CHAR (for example TMMonth),
> the routine, internally calls functions like the localize_month and
> localize_day to get the localized value.
> These functions rely on the current locale category that is internally
> loaded by GetText "engine". 
> The GetText engine does not load any other locate category unless SET
> LC_MESSAGES or alike is given.
> 
> 
> Now back to TO_DATE: 
> 
> For this there are three solution that I can think of.
> 
> 1. For TO_DATE to return localized data we can implement the TM prefix logic
> which is already
> implemented in TO_CHAR. Copying and modifying it for TO_DATE should be
> feasible.
> The downside of this solution is that TO_DATE will only return localized
> values base on current locale. (no third parameter)

I can't remember anyone asking for more sophisticated solutions so it
seems implementing #1 at this point is the best approach.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://postgres.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Patch review
Next
From: Tom Lane
Date:
Subject: Re: The question of LOCALE at the time of a regression test.