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 */