From d061b384d941d544de4d989c0496e7415e4d4201 Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Tue, 16 Jan 2007 07:57:22 +0000 Subject: [PATCH] Fixed problem with year > 9999. --- ChangeLog | 4 ++++ psycopg/typecast_datetime.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e4ee3672..ae30cbd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-01-16 Federico Di Gregorio + + * psycopg/typecast_datetime.c: fixed problem with year > 9999. + 2006-10-29 Federico Di Gregorio * Applied patch from Jason Erickson to make psycopg build diff --git a/psycopg/typecast_datetime.c b/psycopg/typecast_datetime.c index 3a09f07a..a3919b30 100644 --- a/psycopg/typecast_datetime.c +++ b/psycopg/typecast_datetime.c @@ -59,6 +59,7 @@ typecast_PYDATE_cast(char *str, int len, PyObject *curs) PyErr_SetString(DataError, "unable to parse date"); } else { + if (y > 9999) y = 9999; obj = PyObject_CallFunction(pyDateTypeP, "iii", y, m, d); } } @@ -111,7 +112,9 @@ typecast_PYDATETIME_cast(char *str, int len, PyObject *curs) mm += 1; ss -= 60; } - + if (y > 9999) + y = 9999; + if (n == 5 && ((cursorObject*)curs)->tzinfo_factory != Py_None) { /* we have a time zone, calculate minutes and create appropriate tzinfo object calling the factory */