summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/datetime.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-05-04 04:30:35 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-05-04 04:30:35 +0000
commitc04e80cf8777f1d3ae5852e9c7afd365f945ac90 (patch)
treeb0c96cf15f27e64bcb69f95e827987807a2dd463 /src/backend/utils/adt/datetime.c
parentf1b3af29c1d5bd7575424c798b33de0c45e8f5d8 (diff)
Allow 60 in seconds fields of timestamp, time, interval input values.
Per recent discussion on pgsql-general, this is appropriate for spec compliance, and has the nice side-effect of easing porting from old pg_dump files that exhibit the 59.999=>60.000 roundoff problem.
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r--src/backend/utils/adt/datetime.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 0ce56d07746..20c45bee32d 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.96.2.4 2003/02/20 05:25:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.96.2.5 2003/05/04 04:30:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2061,15 +2061,16 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
tm->tm_hour += 12;
#ifdef HAVE_INT64_TIMESTAMP
- if (((tm->tm_hour < 0) || (tm->tm_hour > 23))
- || ((tm->tm_min < 0) || (tm->tm_min > 59))
- || ((tm->tm_sec < 0) || (tm->tm_sec > 60))
+ if ((tm->tm_hour < 0) || (tm->tm_hour > 23)
+ || (tm->tm_min < 0) || (tm->tm_min > 59)
+ || (tm->tm_sec < 0) || (tm->tm_sec > 60)
|| (*fsec < INT64CONST(0)) || (*fsec >= INT64CONST(1000000)))
return -1;
#else
- if (((tm->tm_hour < 0) || (tm->tm_hour > 23))
- || ((tm->tm_min < 0) || (tm->tm_min > 59))
- || ((tm->tm_sec < 0) || ((tm->tm_sec + *fsec) >= 60)))
+ if ((tm->tm_hour < 0) || (tm->tm_hour > 23)
+ || (tm->tm_min < 0) || (tm->tm_min > 59)
+ || (tm->tm_sec < 0) || (tm->tm_sec > 60)
+ || (*fsec < 0) || (*fsec >= 1))
return -1;
#endif
@@ -2294,14 +2295,14 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
#ifdef HAVE_INT64_TIMESTAMP
if ((tm->tm_hour < 0)
|| (tm->tm_min < 0) || (tm->tm_min > 59)
- || (tm->tm_sec < 0) || (tm->tm_sec > 59)
- || (*fsec >= INT64CONST(1000000)))
+ || (tm->tm_sec < 0) || (tm->tm_sec > 60)
+ || (*fsec < INT64CONST(0)) || (*fsec >= INT64CONST(1000000)))
return -1;
#else
if ((tm->tm_hour < 0)
|| (tm->tm_min < 0) || (tm->tm_min > 59)
- || (tm->tm_sec < 0) || (tm->tm_sec > 59)
- || (*fsec >= 1))
+ || (tm->tm_sec < 0) || (tm->tm_sec > 60)
+ || (*fsec < 0) || (*fsec >= 1))
return -1;
#endif