aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/datetime.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-06-25 21:14:15 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-06-25 21:14:15 +0000
commit621691d816c45396ab9f8f9486ee9eb2a037795c (patch)
tree4b96c2d96bac61e36754b539c2398db4f72a688d /src/backend/utils/adt/datetime.c
parentd2ba12b4ef39aee8162fa391a353bbb6b4d3c0d0 (diff)
downloadpostgresql-621691d816c45396ab9f8f9486ee9eb2a037795c.tar.gz
postgresql-621691d816c45396ab9f8f9486ee9eb2a037795c.zip
In ISO datestyle, never emit just HH:MM, always emit HH:MM:SS or
HH:MM:SS.SSS... when there is a nonzero part-of-a-day field in an interval value. The seconds part used to be suppressed if zero, but there's no equivalent behavior for timestamp, and since we're modeling this format on timestamp it's probably wrong. Per complaint and patch from Larry Rosenman.
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r--src/backend/utils/adt/datetime.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 31b42d4612f..288203389bb 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.105 2003/05/18 01:06:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.106 2003/06/25 21:14:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3510,6 +3510,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
is_before = (tm->tm_mday < 0);
is_nonzero = TRUE;
}
+
if ((!is_nonzero) || (tm->tm_hour != 0) || (tm->tm_min != 0)
|| (tm->tm_sec != 0) || (fsec != 0))
{
@@ -3523,7 +3524,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
/* Mark as "non-zero" since the fields are now filled in */
is_nonzero = TRUE;
- /* fractional seconds? */
+ /* need fractional seconds? */
if (fsec != 0)
{
#ifdef HAVE_INT64_TIMESTAMP
@@ -3536,14 +3537,11 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
#endif
TrimTrailingZeros(cp);
cp += strlen(cp);
- is_nonzero = TRUE;
}
- /* otherwise, integer seconds only? */
- else if (tm->tm_sec != 0)
+ else
{
sprintf(cp, ":%02d", abs(tm->tm_sec));
cp += strlen(cp);
- is_nonzero = TRUE;
}
}
break;