MCPcopy
hub / github.com/django/django / as_datetime

Method as_datetime

django/contrib/gis/gdal/field.py:72–93  ·  view source on GitHub ↗

Retrieve the Field's value as a tuple of date & time components.

(self)

Source from the content-addressed store, hash-verified

70 return force_str(string, encoding=self._feat.encoding, strings_only=True)
71
72 def as_datetime(self):
73 "Retrieve the Field's value as a tuple of date & time components."
74 if not self.is_set:
75 return None
76 yy, mm, dd, hh, mn, ss, tz = [c_int() for i in range(7)]
77 status = capi.get_field_as_datetime(
78 self._feat.ptr,
79 self._index,
80 byref(yy),
81 byref(mm),
82 byref(dd),
83 byref(hh),
84 byref(mn),
85 byref(ss),
86 byref(tz),
87 )
88 if status:
89 return (yy, mm, dd, hh, mn, ss, tz)
90 else:
91 raise GDALException(
92 "Unable to retrieve date & time information from the field."
93 )
94
95 # #### Field Properties ####
96 @property

Callers 3

valueMethod · 0.80
valueMethod · 0.80
valueMethod · 0.80

Calls 1

GDALExceptionClass · 0.90

Tested by

no test coverage detected