diff --git a/ChangeLog b/ChangeLog index c80c6a7b..76d213e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2006-09-30 Federico Di Gregorio + * ZpsycopgDA/DA.py: applied the infinity patch from 1.1 (fixes #122). + * psycopg/adapter_datetime.py: fixed conversion problem with seconds in the (59,60) range (fixes #131). diff --git a/ZPsycopgDA/DA.py b/ZPsycopgDA/DA.py index ba0443f3..f8cd04a4 100644 --- a/ZPsycopgDA/DA.py +++ b/ZPsycopgDA/DA.py @@ -221,7 +221,10 @@ for icon in ('table', 'view', 'stable', 'what', 'field', 'text', 'bin', # convert an ISO timestamp string from postgres to a Zope DateTime object def _cast_DateTime(iso, curs): if iso: - return DateTime(re.split("GMT\+?|GMT-?|\+|-", iso)[0]) + if iso in ['-infinity', 'infinity']: + return iso + else: + return DateTime(re.split("GMT\+?|GMT-?|\+|-", iso)[0]) # this will split us into [date, time, GMT/AM/PM(if there)] # dt = str.split(' ') @@ -236,14 +239,20 @@ def _cast_DateTime(iso, curs): # convert an ISO date string from postgres to a Zope DateTime object def _cast_Date(iso, curs): if iso: - return DateTime(iso) + if iso in ['-infinity', 'infinity']: + return iso + else: + return DateTime(iso) # Convert a time string from postgres to a Zope DateTime object. # NOTE: we set the day as today before feeding to DateTime so # that it has the same DST settings. def _cast_Time(iso, curs): if iso: - return DateTime(time.strftime('%Y-%m-%d %H:%M:%S', + if iso in ['-infinity', 'infinity']: + return iso + else: + return DateTime(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())[:3]+ time.strptime(iso[:8], "%H:%M:%S")[3:]))