TH to_char modifier doesn't work with HH12
TH to_char modifier doesn't work with HH12
От:
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Дата:
The uppercase 'TH' modifier is not working with HH12:
template1=# select to_char('3-MAY-2007 2:34'::timestamptz,'FMHHTH" HOUR
OF THE "FMDDTH" DAY WAS ILL-FATED'::text);
to_char
---------------------------------------
2nd HOUR OF THE 3RD DAY WAS ILL-FATED
(1 row)
Looking at the code, that looks like an oversight and the fix is trivial:
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -2094,7 +2094,7 @@ DCH_to_char(FormatNode *node, bool is_interval,
TmToChar *
tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 :
tm->tm_hour % (HOURS_PER_DAY / 2));
if (S_THth(n->suffix))
- str_numth(s, s, 0);
+ str_numth(s, s, S_TH_TYPE(n->suffix));
s += strlen(s);
break;
case DCH_HH24:
But given that it has been like that at least back to 8.0 which is the
oldest version I have installed right now: does anyone see a reason not
to fix that?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.comRe: TH to_char modifier doesn't work with HH12
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Heikki Linnakangas writes: > Looking at the code, that looks like an oversight and the fix is trivial: Yeah, I think you are right. > But given that it has been like that at least back to 8.0 which is the > oldest version I have installed right now: does anyone see a reason not > to fix that? +1 for backpatching as far as you conveniently can. regards, tom lane
Re: TH to_char modifier doesn't work with HH12
От:
Bruce Momjian <bruce@momjian.us>
Дата:
Tom Lane wrote: > Heikki Linnakangas writes: > > Looking at the code, that looks like an oversight and the fix is trivial: > > Yeah, I think you are right. > > > But given that it has been like that at least back to 8.0 which is the > > oldest version I have installed right now: does anyone see a reason not > > to fix that? > > +1 for backpatching as far as you conveniently can. Will we be _forever_ fixing coding mistakes in formatting.c? -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Re: TH to_char modifier doesn't work with HH12
От:
David Fetter <david@fetter.org>
Дата:
On Mon, Jul 06, 2009 at 01:53:28PM -0400, Bruce Momjian wrote: > Tom Lane wrote: > > Heikki Linnakangas writes: > > > Looking at the code, that looks like an oversight and the fix is > > > trivial: > > > > Yeah, I think you are right. > > > > > But given that it has been like that at least back to 8.0 which > > > is the oldest version I have installed right now: does anyone > > > see a reason not to fix that? > > > > +1 for backpatching as far as you conveniently can. > > Will we be _forever_ fixing coding mistakes in formatting.c? That depends on whether the project lasts forever ;) Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
Re: TH to_char modifier doesn't work with HH12
От:
Bruce Momjian <bruce@momjian.us>
Дата:
David Fetter wrote: > On Mon, Jul 06, 2009 at 01:53:28PM -0400, Bruce Momjian wrote: > > Tom Lane wrote: > > > Heikki Linnakangas writes: > > > > Looking at the code, that looks like an oversight and the fix is > > > > trivial: > > > > > > Yeah, I think you are right. > > > > > > > But given that it has been like that at least back to 8.0 which > > > > is the oldest version I have installed right now: does anyone > > > > see a reason not to fix that? > > > > > > +1 for backpatching as far as you conveniently can. > > > > Will we be _forever_ fixing coding mistakes in formatting.c? > > That depends on whether the project lasts forever ;) I feel like someone should take a flame-thrower to that file. ;-) -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Re: TH to_char modifier doesn't work with HH12
От:
Greg Stark <gsstark@mit.edu>
Дата:
On Mon, Jul 6, 2009 at 7:20 PM, Bruce Momjian wrote: > I feel like someone should take a flame-thrower to that file. =A0;-) If you were half the man you used to be would you? --=20 greg http://mit.edu/~gsstark/resume.pdf
Re: TH to_char modifier doesn't work with HH12
От:
Bruce Momjian <bruce@momjian.us>
Дата:
Greg Stark wrote: > On Mon, Jul 6, 2009 at 7:20 PM, Bruce Momjian wrote: > > I feel like someone should take a flame-thrower to that file. ?;-) > > If you were half the man you used to be would you? I thought we had flame-throwed it a couple of of times, with overhauls, but obviously we didn't do a thorough enough job. I am thinking there is something structurally/fundamentally wrong with a file that continually has so many bugs. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Re: TH to_char modifier doesn't work with HH12
От:
David Fetter <david@fetter.org>
Дата:
On Mon, Jul 06, 2009 at 02:30:12PM -0400, Bruce Momjian wrote: > Greg Stark wrote: > > On Mon, Jul 6, 2009 at 7:20 PM, Bruce Momjian wrote: > > > I feel like someone should take a flame-thrower to that file. > > > ?;-) > > > > If you were half the man you used to be would you? > > I thought we had flame-throwed it a couple of of times, with > overhauls, but obviously we didn't do a thorough enough job. I am > thinking there is something structurally/fundamentally wrong with a > file that continually has so many bugs. Dunno about the file, but the whole question of date and time handling has been tricky and complicated for all of human history. Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
Re: TH to_char modifier doesn't work with HH12
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
David Fetter writes: > On Mon, Jul 6, 2009 at 7:20 PM, Bruce Momjian wrote: >>> I feel like someone should take a flame-thrower to that file. > Dunno about the file, but the whole question of date and time handling > has been tricky and complicated for all of human history. Yeah. I think about half the problem is it wasn't tremendously well written, and half is that it's written to a nonexistent or at least completely underdetermined specification. If we want to do something about it, my thought is that writing a real spec would be the right first step. regards, tom lane
Re: TH to_char modifier doesn't work with HH12
От:
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Дата:
David Fetter wrote: > Dunno about the file, but the whole question of date and time handling > has been tricky and complicated for all of human history. Yeah, the rules on how to parse the pattern and how to use it to interpret/format dates are indeed very complex. And this was a particularly obscure example. Anyway, fixed back to 8.0 now. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com