summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2009-01-07 20:23:23 +0000
committerJustin Bronn <jbronn@gmail.com>2009-01-07 20:23:23 +0000
commitf3f251a6dea1e9387a6a47d5cea3cfcdaa168ce2 (patch)
treecfa4e90d02f76726de0ae3caffa9fda362ae515d
parentf6cacacbfffca4676be10b439f295207e5ee8ba7 (diff)
[1.0.X] Return None for null date/time fields in OGR-supported data sources. Thanks to Ariel Mauricio Nunez Gomez for bug report and initial patch.
Backport of r9711 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9712 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/gis/gdal/field.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py
index ad1feb3d22..6374bc7d80 100644
--- a/django/contrib/gis/gdal/field.py
+++ b/django/contrib/gis/gdal/field.py
@@ -127,34 +127,34 @@ class OFTDate(Field):
@property
def value(self):
"Returns a Python `date` object for the OFTDate field."
- yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
try:
+ yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
return date(yy.value, mm.value, dd.value)
- except ValueError:
+ except (ValueError, OGRException):
return None
class OFTDateTime(Field):
@property
def value(self):
"Returns a Python `datetime` object for this OFTDateTime field."
- yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
# TODO: Adapt timezone information.
# See http://lists.maptools.org/pipermail/gdal-dev/2006-February/007990.html
# The `tz` variable has values of: 0=unknown, 1=localtime (ambiguous),
# 100=GMT, 104=GMT+1, 80=GMT-5, etc.
try:
+ yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
return datetime(yy.value, mm.value, dd.value, hh.value, mn.value, ss.value)
- except ValueError:
+ except (ValueError, OGRException):
return None
class OFTTime(Field):
@property
def value(self):
"Returns a Python `time` object for this OFTTime field."
- yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
try:
+ yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
return time(hh.value, mn.value, ss.value)
- except ValueError:
+ except (ValueError, OGRException):
return None
# List fields are also just subclasses