MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / parse

Method parse

suds/sax/date.py:131–152  ·  view source on GitHub ↗

Parse the string date. This supports the subset of ISO8601 used by xsd:time, but is lenient with what is accepted, handling most reasonable syntax. @param value: A time string. @type value: str @return: A time object. @rtype: B{datetime}.I{time}

(value)

Source from the content-addressed store, hash-verified

129
130 @staticmethod
131 def parse(value):
132 """Parse the string date.
133
134 This supports the subset of ISO8601 used by xsd:time, but is lenient
135 with what is accepted, handling most reasonable syntax.
136
137 @param value: A time string.
138 @type value: str
139 @return: A time object.
140 @rtype: B{datetime}.I{time}
141
142 """
143 match_result = RE_TIME.match(value)
144 if match_result is None:
145 raise ValueError('date data has invalid format "%s"' % (value, ))
146
147 date = time_from_match(match_result)
148 tzinfo = tzinfo_from_match(match_result)
149
150 value = date.replace(tzinfo=tzinfo)
151
152 return value
153
154 def __str__(self):
155 return self.value.isoformat()

Callers 1

__init__Method · 0.95

Calls 3

time_from_matchFunction · 0.85
tzinfo_from_matchFunction · 0.85
matchMethod · 0.45

Tested by

no test coverage detected