Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Return None for null date/time fields in OGR-supported data sources. …

…Thanks to Ariel Mauricio Nunez Gomez for bug report and initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9711 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 300752bd6c0bfdf3bdf85e61fed318f4e587b16a 1 parent bde7e79
Justin Bronn authored January 07, 2009

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. 12  django/contrib/gis/gdal/field.py
12  django/contrib/gis/gdal/field.py
@@ -127,34 +127,34 @@ class OFTDate(Field):
127 127
     @property
128 128
     def value(self):
129 129
         "Returns a Python `date` object for the OFTDate field."
130  
-        yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
131 130
         try:
  131
+            yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
132 132
             return date(yy.value, mm.value, dd.value)
133  
-        except ValueError:
  133
+        except (ValueError, OGRException):
134 134
             return None
135 135
 
136 136
 class OFTDateTime(Field):
137 137
     @property
138 138
     def value(self):
139 139
         "Returns a Python `datetime` object for this OFTDateTime field."
140  
-        yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
141 140
         # TODO: Adapt timezone information.
142 141
         #  See http://lists.maptools.org/pipermail/gdal-dev/2006-February/007990.html
143 142
         #  The `tz` variable has values of: 0=unknown, 1=localtime (ambiguous), 
144 143
         #  100=GMT, 104=GMT+1, 80=GMT-5, etc.
145 144
         try:
  145
+            yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
146 146
             return datetime(yy.value, mm.value, dd.value, hh.value, mn.value, ss.value)
147  
-        except ValueError:
  147
+        except (ValueError, OGRException):
148 148
             return None
149 149
 
150 150
 class OFTTime(Field):
151 151
     @property
152 152
     def value(self):
153 153
         "Returns a Python `time` object for this OFTTime field."
154  
-        yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
155 154
         try:
  155
+            yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
156 156
             return time(hh.value, mn.value, ss.value)
157  
-        except ValueError:
  157
+        except (ValueError, OGRException):
158 158
             return None
159 159
 
160 160
 # List fields are also just subclasses

0 notes on commit 300752b

Please sign in to comment.
Something went wrong with that request. Please try again.