postgres.git / summary / log / commit / refs
commit 7cdadc62eac79ee9bd05b6a74d3ddfb96924a439
Author: Bruce Momjian <bruce@momjian.us>
Date: Tue Feb 23 01:42:19 2010 +0000
First released in: 9.0.0
Supress convertion of zero hours to '12' for intervals when using
to_char with HH, e.g.
to_char(interval '0d 0h 12m 44s', 'DD HH24 MI SS');
now returns:
00 00 12 44
not:
00 12 12 44
src/backend/utils/adt/formatting.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index a3e7f0c76bb..1db285536fe 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.163 2010/02/16 21:18:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.164 2010/02/23 01:42:19 momjian Exp $
*
*
* Portions Copyright (c) 1999-2010, PostgreSQL Global Development Group
@@ -2089,8 +2089,8 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
case DCH_HH:
case DCH_HH12:
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2,
- tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 :
- tm->tm_hour % (HOURS_PER_DAY / 2));
+ !is_interval && 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, S_TH_TYPE(n->suffix));
s += strlen(s);
[parent: 485b19ec3c60]