Skip to content

Commit 7cdadc6

Browse files
committed
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
1 parent 485b19e commit 7cdadc6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/adt/formatting.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* formatting.c
33
*
4-
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.163 2010/02/16 21:18:01 momjian Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.164 2010/02/23 01:42:19 momjian Exp $
55
*
66
*
77
* 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)
20892089
case DCH_HH:
20902090
case DCH_HH12:
20912091
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2,
2092-
tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 :
2093-
tm->tm_hour % (HOURS_PER_DAY / 2));
2092+
!is_interval && tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ?
2093+
12 : tm->tm_hour % (HOURS_PER_DAY / 2));
20942094
if (S_THth(n->suffix))
20952095
str_numth(s, s, S_TH_TYPE(n->suffix));
20962096
s += strlen(s);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy