-
+
Functions and Operators
to_char(interval) formats HH> and
- HH12> as hours in a single day, while HH24>
- can output hours exceeding a single day, e.g., >24.
+ HH12> as shown on a 12-hour clock, i.e. zero hours
+ and 36 hours output as 12>, while HH24>
+ outputs the full hour value, which can exceed 23 for intervals.
/* -----------------------------------------------------------------------
* formatting.c
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.165 2010/02/23 06:29:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.166 2010/02/23 16:14:26 momjian Exp $
*
*
* Portions Copyright (c) 1999-2010, PostgreSQL Global Development Group
break;
case DCH_HH:
case DCH_HH12:
+ /* display time as shown on a 12-hour clock, even for intervals */
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2,
- is_interval ? tm->tm_hour :
- tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ?
- 12 : tm->tm_hour % (HOURS_PER_DAY / 2));
+ 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);