Skip to content

Commit 0bf80d6

Browse files
committed
support timezone data in iso date strings
The latest release of the isodate package (0.7.2) doesn’t handle timezone information for dates. While this is indeed not valid according to the ISO specs we want to handle it anway. At a workaround by stripping the timezone data ourselves
1 parent 5f35e85 commit 0bf80d6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/zeep/xsd/types/builtins.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,19 @@ def xmlvalue(self, value):
210210

211211
@treat_whitespace("collapse")
212212
def pythonvalue(self, value):
213-
return isodate.parse_date(value)
213+
try:
214+
return isodate.parse_date(value)
215+
except isodate.ISO8601Error:
216+
# Recent versions of isodate don't support timezone in date's. This
217+
# is not really ISO8601 compliant anway, but we should try to handle
218+
# it. This is a hack to support this.
219+
if "+" in value:
220+
value = value.split("+")[0]
221+
return isodate.parse_date(value)
222+
if "Z" in value:
223+
value = value.split("Z")[0]
224+
return isodate.parse_date(value)
225+
raise
214226

215227

216228
class gYearMonth(BuiltinType):

0 commit comments

Comments
 (0)