File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 1+ 4.3.1 (2024-10-16)
2+ ------------------
3+ - Fix regression in parsing xsd:Date with negative timezone
4+
154.3.0 (2024-10-13)
26------------------
37 - Drop support for Python 3.7 and 3.8 and add support for Python 3.12 and 3.13 (#1421, #1408)
Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ def pythonvalue(self, value):
201201class Date (BuiltinType ):
202202 _default_qname = xsd_ns ("date" )
203203 accepted_types = [datetime .date , str ]
204+ _pattern = re .compile (r"(\d{4})-(\d{2})-(\d{2})" )
204205
205206 @check_no_collection
206207 def xmlvalue (self , value ):
@@ -215,13 +216,10 @@ def pythonvalue(self, value):
215216 except isodate .ISO8601Error :
216217 # Recent versions of isodate don't support timezone in date's. This
217218 # 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 )
219+ # it, so lets just use a regex to parse the date directly.
220+ m = self ._pattern .match (value )
221+ if m :
222+ return datetime .date (* map (int , m .groups ()))
225223 raise
226224
227225
Original file line number Diff line number Diff line change @@ -242,6 +242,8 @@ def test_pythonvalue(self):
242242 instance = builtins .Date ()
243243 assert instance .pythonvalue ("2016-03-04" ) == datetime .date (2016 , 3 , 4 )
244244 assert instance .pythonvalue ("2001-10-26+02:00" ) == datetime .date (2001 , 10 , 26 )
245+ assert instance .pythonvalue ("2001-10-26-02:00" ) == datetime .date (2001 , 10 , 26 )
246+ assert instance .pythonvalue ("2024-08-21-10:00" ) == datetime .date (2024 , 8 , 21 )
245247 assert instance .pythonvalue ("2001-10-26Z" ) == datetime .date (2001 , 10 , 26 )
246248 assert instance .pythonvalue ("2001-10-26+00:00" ) == datetime .date (2001 , 10 , 26 )
247249 assert instance .pythonvalue ("\r \n \t 2016-03-04 " ) == datetime .date (2016 , 3 , 4 )
You can’t perform that action at this time.
0 commit comments