[Zope3-checkins] CVS: Zope3/lib/python/Zope/Misc/tests - testDateTimeParse.py:1.4
Marius Gedminas
mgedmin@codeworks.lt
Mon, 18 Nov 2002 07:22:28 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Misc/tests
In directory cvs.zope.org:/tmp/cvs-serv24949/tests
Modified Files:
testDateTimeParse.py
Log Message:
Rewrote UTC offset parsing in __parse8601 to accept different legal variations
(+hh, +hhmm +hh:mm) and do the right thing with -00:mm
Dropped GMT prefix from timezone returned by __parse8601.
Round microseconds in parseDatetimetz, otherwise "0.037" gets transformed into
36999 us.
Added unit tests for everything mentioned above.
Added tzinfo.__repr__ to make assertEquals failues more explicit.
=== Zope3/lib/python/Zope/Misc/tests/testDateTimeParse.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Misc/tests/testDateTimeParse.py:1.3 Mon Nov 18 06:46:43 2002
+++ Zope3/lib/python/Zope/Misc/tests/testDateTimeParse.py Mon Nov 18 07:22:27 2002
@@ -47,6 +47,9 @@
3456)
self.assertEqual(parse('Tue, 24 Jul 2001 09:41:03 -0400'),
(2001, 7, 24, 9, 41, 3, '-0400'))
+ self.assertEqual(parse('1999-12-31T01:02:03.456-12')[6], '-1200')
+ self.assertEqual(parse('1999-12-31T01:02:03.456+0030')[6], '+0030')
+ self.assertEqual(parse('1999-12-31T01:02:03.456-00:30')[6], '-0030')
def testTime(self):
from time import gmtime
@@ -84,6 +87,12 @@
self.assertEqual(_tzoffset('-0030', None), -30*60)
self.assertEqual(_tzoffset('+0200', None), 2*60*60)
self.assertEqual(_tzoffset('EET', None), 2*60*60)
+
+ def testParseDatetimetz(self):
+ from datetime import datetimetz
+ from Zope.Misc.DateTimeParse import parseDatetimetz, tzinfo
+ self.assertEqual(parseDatetimetz('1999-12-31T01:02:03.037-00:30'),
+ datetimetz(1999, 12, 31, 1, 2, 3, 37000, tzinfo(-30)))
def test_suite():
loader=unittest.TestLoader()