aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/nabstime.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-10-14 11:47:57 +0000
committerBruce Momjian <bruce@momjian.us>2005-10-14 11:47:57 +0000
commita93bf4503ffc6d7cd6243a6324fb2ef206b10adf (patch)
treeb42cbc485e4250d2b1116ac9e52a5ac94f7d1d5f /src/backend/utils/adt/nabstime.c
parentdbc214f7e611ed32bd8208955486ba46d2dbc941 (diff)
downloadpostgresql-a93bf4503ffc6d7cd6243a6324fb2ef206b10adf.tar.gz
postgresql-a93bf4503ffc6d7cd6243a6324fb2ef206b10adf.zip
Allow times of 24:00:00 to match rounding behavior:
regression=# select '23:59:59.9'::time(0); time ---------- 24:00:00 (1 row) This is bad because: regression=# select '24:00:00'::time(0); ERROR: date/time field value out of range: "24:00:00" The last example now works.
Diffstat (limited to 'src/backend/utils/adt/nabstime.c')
-rw-r--r--src/backend/utils/adt/nabstime.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index d097b51e8bf..148ee0abb1c 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.143 2005/09/24 22:54:38 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.144 2005/10/14 11:47:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,12 +184,14 @@ tm2abstime(struct pg_tm *tm, int tz)
AbsoluteTime sec;
/* validate, before going out of range on some members */
- if (tm->tm_year < 1901 || tm->tm_year > 2038
- || tm->tm_mon < 1 || tm->tm_mon > 12
- || tm->tm_mday < 1 || tm->tm_mday > 31
- || 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_year < 1901 || tm->tm_year > 2038 ||
+ tm->tm_mon < 1 || tm->tm_mon > 12 ||
+ tm->tm_mday < 1 || tm->tm_mday > 31 ||
+ tm->tm_hour < 0 ||
+ tm->tm_hour > 24 || /* test for > 24:00:00 */
+ (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0)) ||
+ tm->tm_min < 0 || tm->tm_min > 59 ||
+ tm->tm_sec < 0 || tm->tm_sec > 60)
return INVALID_ABSTIME;
day = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - UNIX_EPOCH_JDATE;