Difference between Python and Postgres locale currency formats

Started by Christian Jauvinabout 13 years ago2 messagesgeneral
Jump to latest
#1Christian Jauvin
cjauvin@gmail.com

Hi,

First, I already posted that question to SO, if you prefer to answer it there:

http://stackoverflow.com/questions/15882501/difference-between-python-and-postgres-locale-currency-formats

Using Python 2.6, I get:

import locale
locale.setlocale(locale.LC_MONETARY, 'fr_CA.UTF-8')
locale.currency(1.234) # '1,23 $'

while using Postgres 9.1:

set lc_monetary = 'fr_CA.UTF-8';
select 1.234::money; -- '$1,23'

I think the Python version is the right one (not 100% sure though),
but how can they possibly be different?

Thanks,

Christian

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christian Jauvin (#1)
Re: Difference between Python and Postgres locale currency formats

Christian Jauvin <cjauvin@gmail.com> writes:

while using Postgres 9.1:

set lc_monetary = 'fr_CA.UTF-8';
select 1.234::money; -- '$1,23'

That was changed in 9.2 --- per the release notes:

Support more locale-specific formatting options for the money
data type (Tom Lane)

Specifically, honor all the POSIX options for ordering of the
value, sign, and currency symbol in monetary output. Also, make
sure that the thousands separator is only inserted to the left
of the decimal point, as required by POSIX.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general