FM suffix in to_char Y/YY/YYY still screwy - Mailing list pgsql-hackers

From Tom Lane
Subject FM suffix in to_char Y/YY/YYY still screwy
Date
Msg-id 21721.1270673174@sss.pgh.pa.us
Whole thread Raw
Responses Re: FM suffix in to_char Y/YY/YYY still screwy  (Brendan Jurd <direvus@gmail.com>)
Re: FM suffix in to_char Y/YY/YYY still screwy  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
I thought we'd fixed this ...

regression=# select to_char('2009-01-01'::date, 'YY');to_char 
---------09
(1 row)

regression=# select to_char('2009-01-01'::date, 'FMYY');to_char 
---------09
(1 row)

Not a lot of zero suppression happening there :-(.

I believe the correct fix is to reduce the year mod 100 (or 10 or 1000)
before feeding it to snprintf, rather than playing games with printing
only part of the result string as the original and current code try to
do.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Dhiraj Lohiya
Date:
Subject: Enhancing phonetic search support for more languages - GSoC 2010
Next
From: Josh Berkus
Date:
Subject: Re: Enhancing phonetic search support for more languages - GSoC 2010