Index: doc/src/sgml/func.sgml =================================================================== RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v retrieving revision 1.296 diff -c -c -r1.296 func.sgml *** doc/src/sgml/func.sgml 28 Nov 2005 23:18:48 -0000 1.296 --- doc/src/sgml/func.sgml 2 Dec 2005 03:51:45 -0000 *************** *** 4749,4754 **** --- 4749,4762 ---- extract function. + + + to_char(interval) formats HH and + HH12 to hours in a single day, while HH24 + can output hours exceeding a single day, e.g. >24. + + + Index: src/backend/utils/adt/formatting.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v retrieving revision 1.102 diff -c -c -r1.102 formatting.c *** src/backend/utils/adt/formatting.c 22 Nov 2005 18:17:22 -0000 1.102 --- src/backend/utils/adt/formatting.c 2 Dec 2005 03:51:51 -0000 *************** *** 1722,1732 **** { case DCH_A_M: case DCH_P_M: - INVALID_FOR_INTERVAL; if (is_to_char) { ! strcpy(inout, ((tm->tm_hour > 11 ! && tm->tm_hour < HOURS_PER_DAY) ? P_M_STR : A_M_STR)); return strlen(p_inout); } else --- 1722,1731 ---- { case DCH_A_M: case DCH_P_M: if (is_to_char) { ! strcpy(inout, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2) ! ? P_M_STR : A_M_STR); return strlen(p_inout); } else *************** *** 1742,1752 **** break; case DCH_AM: case DCH_PM: - INVALID_FOR_INTERVAL; if (is_to_char) { ! strcpy(inout, ((tm->tm_hour > 11 ! && tm->tm_hour < HOURS_PER_DAY) ? PM_STR : AM_STR)); return strlen(p_inout); } else --- 1741,1750 ---- break; case DCH_AM: case DCH_PM: if (is_to_char) { ! strcpy(inout, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2) ! ? PM_STR : AM_STR); return strlen(p_inout); } else *************** *** 1762,1772 **** break; case DCH_a_m: case DCH_p_m: - INVALID_FOR_INTERVAL; if (is_to_char) { ! strcpy(inout, ((tm->tm_hour > 11 ! && tm->tm_hour < HOURS_PER_DAY) ? p_m_STR : a_m_STR)); return strlen(p_inout); } else --- 1760,1769 ---- break; case DCH_a_m: case DCH_p_m: if (is_to_char) { ! strcpy(inout, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2) ! ? p_m_STR : a_m_STR); return strlen(p_inout); } else *************** *** 1782,1792 **** break; case DCH_am: case DCH_pm: - INVALID_FOR_INTERVAL; if (is_to_char) { ! strcpy(inout, ((tm->tm_hour > 11 ! && tm->tm_hour < HOURS_PER_DAY) ? pm_STR : am_STR)); return strlen(p_inout); } else --- 1779,1788 ---- break; case DCH_am: case DCH_pm: if (is_to_char) { ! strcpy(inout, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2) ! ? pm_STR : am_STR); return strlen(p_inout); } else *************** *** 1804,1815 **** case DCH_HH12: if (is_to_char) { ! if (is_interval) ! sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_hour); ! else ! sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, ! tm->tm_hour == 0 ? 12 : ! tm->tm_hour < 13 ? tm->tm_hour : tm->tm_hour - 12); if (S_THth(suf)) str_numth(p_inout, inout, 0); return strlen(p_inout); --- 1800,1808 ---- case DCH_HH12: if (is_to_char) { ! sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, ! tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 : ! tm->tm_hour % (HOURS_PER_DAY / 2)); if (S_THth(suf)) str_numth(p_inout, inout, 0); return strlen(p_inout); *************** *** 2312,2318 **** } break; case DCH_D: - INVALID_FOR_INTERVAL; if (is_to_char) { sprintf(inout, "%d", tm->tm_wday + 1); --- 2305,2310 ----