diff options
| author | Federico Di Gregorio <fog@initd.org> | 2006-09-30 06:39:51 +0000 |
|---|---|---|
| committer | Federico Di Gregorio <fog@initd.org> | 2006-09-30 06:39:51 +0000 |
| commit | 5689f07de49af1b716b68efd9eaed63bd2f6af8c (patch) | |
| tree | 2f51349eb0bd551253ed1d5f6730cec6dd1992a6 | |
| parent | 4820213b7f19fba656f84c73a2d999343c2ab3f8 (diff) | |
| download | psycopg2-5689f07de49af1b716b68efd9eaed63bd2f6af8c.tar.gz | |
Infinity ok in Zope (closes: #122)
| -rw-r--r-- | ChangeLog | 2 | ||||
| -rw-r--r-- | ZPsycopgDA/DA.py | 15 |
2 files changed, 14 insertions, 3 deletions
@@ -1,5 +1,7 @@ 2006-09-30 Federico Di Gregorio <fog@initd.org> + * 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 ba0443f..f8cd04a 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:])) |
