1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Display only 9 subsecond digits instead of 10 for time values, for

consistency and to prevent rounding for days < 30.  Also round off all
trailing zeros, rather than leaving an even number of digits.
This commit is contained in:
Bruce Momjian
2005-05-27 21:31:23 +00:00
parent 5dafb69e17
commit d4b50caf25
3 changed files with 25 additions and 28 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.149 2005/05/27 15:16:44 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.150 2005/05/27 21:31:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -3461,12 +3461,9 @@ EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str)
#ifdef HAVE_INT64_TIMESTAMP
sprintf(str + strlen(str), ":%02d.%06d", tm->tm_sec, fsec);
#else
sprintf(str + strlen(str), ":%013.10f", tm->tm_sec + fsec);
sprintf(str + strlen(str), ":%012.9f", tm->tm_sec + fsec);
#endif
/* chop off trailing pairs of zeros... */
while (strcmp((str + strlen(str) - 2), "00") == 0 &&
*(str + strlen(str) - 3) != '.')
*(str + strlen(str) - 2) = '\0';
TrimTrailingZeros(str);
}
else
sprintf(str + strlen(str), ":%02d", tm->tm_sec);
@ -3804,7 +3801,7 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
sprintf(cp, ".%06d", Abs(fsec));
#else
fsec += tm->tm_sec;
sprintf(cp, ":%013.10f", fabs(fsec));
sprintf(cp, ":%012.9f", fabs(fsec));
#endif
TrimTrailingZeros(cp);
cp += strlen(cp);