diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-10-09 17:21:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-10-09 17:21:47 +0000 |
commit | 313ed1ed9498f977262e180a080c7748197ced5c (patch) | |
tree | 17780e929d9a0d710d84de261b27ac26e9a5adcf /src/backend/utils/adt/datetime.c | |
parent | 7754f7634cbc837702428bbb40a0efbeec7a51d1 (diff) | |
download | postgresql-313ed1ed9498f977262e180a080c7748197ced5c.tar.gz postgresql-313ed1ed9498f977262e180a080c7748197ced5c.zip |
Fix (hopefully for the last time) problems with datetime values displaying
like '23:59:60' because of fractional-second roundoff problems. Trying
to control this upstream of the actual display code was hopeless; the right
way is to explicitly round fractional seconds in the display code and then
refigure the results if the fraction rounds up to 1. Per bug #1927.
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 9e5be7d4cff..74dda5441f1 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.157 2005/07/23 14:25:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.158 2005/10/09 17:21:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3488,8 +3488,8 @@ EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, int *tzp, int style, char *str) sprintf(str, "%02d:%02d", tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here should be - * at least equal to the larger of MAX_TIME_PRECISION and + * Print fractional seconds if any. The fractional field widths + * here should be equal to the larger of MAX_TIME_PRECISION and * MAX_TIMESTAMP_PRECISION. */ if (fsec != 0) @@ -3497,7 +3497,7 @@ 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), ":%012.9f", tm->tm_sec + fsec); + sprintf(str + strlen(str), ":%013.10f", tm->tm_sec + fsec); #endif TrimTrailingZeros(str); } |