aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/utils/adt/datetime.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index fb01c7d30f1..11d293c1842 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.118.2.4 2005/01/11 18:33:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.118.2.5 2005/04/20 17:15:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3858,17 +3858,25 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
/* fractional seconds? */
if (fsec != 0)
{
+ fsec_t sec;
+
#ifdef HAVE_INT64_TIMESTAMP
+ sec = fsec;
if (is_before || ((!is_nonzero) && (tm->tm_sec < 0)))
+ {
tm->tm_sec = -tm->tm_sec;
+ sec = -sec;
+ is_before = TRUE;
+ }
+ else if ((!is_nonzero) && (tm->tm_sec == 0) && (fsec < 0))
+ {
+ sec = -sec;
+ is_before = TRUE;
+ }
sprintf(cp, "%s%d.%02d secs", (is_nonzero ? " " : ""),
- tm->tm_sec, (((int) fsec) / 10000));
+ tm->tm_sec, (((int) sec) / 10000));
cp += strlen(cp);
- if (!is_nonzero)
- is_before = (fsec < 0);
#else
- fsec_t sec;
-
fsec += tm->tm_sec;
sec = fsec;
if (is_before || ((!is_nonzero) && (fsec < 0)))
@@ -3880,9 +3888,8 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
is_before = (fsec < 0);
#endif
is_nonzero = TRUE;
-
- /* otherwise, integer seconds only? */
}
+ /* otherwise, integer seconds only? */
else if (tm->tm_sec != 0)
{
int sec = tm->tm_sec;