[Zope-Checkins] SVN: Zope/trunk/lib/python/DateTime/ Collector #1386: Fixed ISO 1386 parsing, making the colon in the timezone

Martijn Pieters mj at zopatista.com
Fri Jun 25 11:45:44 EDT 2004


Log message for revision 25983:
Collector #1386: Fixed ISO 1386 parsing, making the colon in the timezone
offset optional.



-=-
Modified: Zope/trunk/lib/python/DateTime/DateTime.py
===================================================================
--- Zope/trunk/lib/python/DateTime/DateTime.py	2004-06-25 14:42:18 UTC (rev 25982)
+++ Zope/trunk/lib/python/DateTime/DateTime.py	2004-06-25 15:45:44 UTC (rev 25983)
@@ -1678,11 +1678,11 @@
 
         datereg = re.compile('([0-9]{4})(-([0-9][0-9]))?(-([0-9][0-9]))?')
         timereg = re.compile('T([0-9]{2})(:([0-9][0-9]))?(:([0-9][0-9]))?(\.[0-9]{1,20})?')
-        zonereg = re.compile('([+-][0-9][0-9])(:([0-9][0-9]))')
+        zonereg = re.compile('([+-][0-9][0-9])(:?([0-9][0-9]))')
 
         # Date part
 
-        fields = datereg.split(s.strip())
+        fields = datereg.split(s.strip(), 1)
 
         if fields[1]:   year  = int(fields[1])
         if fields[3]:   month = int(fields[3])

Modified: Zope/trunk/lib/python/DateTime/tests/testDateTime.py
===================================================================
--- Zope/trunk/lib/python/DateTime/tests/testDateTime.py	2004-06-25 14:42:18 UTC (rev 25982)
+++ Zope/trunk/lib/python/DateTime/tests/testDateTime.py	2004-06-25 15:45:44 UTC (rev 25983)
@@ -259,6 +259,10 @@
         isoDt = DateTime('2002-05-02T08:00:00-04:00')
         self.assertEqual( ref1, isoDt)
 
+        # Bug 1386: the colon in the timezone offset is optional
+        isoDt = DateTime('2002-05-02T08:00:00-0400')
+        self.assertEqual( ref1, isoDt)
+        
         dgood = '2002-05-02'
         tgood = 'T08:00:00-04:00'
         for dbad in '2002-5-2', '2002-10-2', '2002-2-10', '02-2-10':



More information about the Zope-Checkins mailing list