[Zope-Checkins] CVS: Zope/lib/python/DateTime/tests - testDateTime.py:1.12.6.6

Lennart Regebro lennart@torped.se
Thu, 16 Jan 2003 11:53:23 -0500


Update of /cvs-repository/Zope/lib/python/DateTime/tests
In directory cvs.zope.org:/tmp/cvs-serv16742/lib/python/DateTime/tests

Modified Files:
      Tag: Zope-2_6-branch
	testDateTime.py 
Log Message:
Merge with 2.6
#740: _tzoffset handled positive numerical offsets incorrectly. This has been fixed. A large set of tests for different cases has been added, and for the purpose of those tests DateTime has a new feature: A tzoffset() method.

=== Zope/lib/python/DateTime/tests/testDateTime.py 1.12.6.5 => 1.12.6.6 ===
--- Zope/lib/python/DateTime/tests/testDateTime.py:1.12.6.5	Tue Oct 29 13:13:12 2002
+++ Zope/lib/python/DateTime/tests/testDateTime.py	Thu Jan 16 11:53:20 2003
@@ -212,9 +212,39 @@
 
     def test_tzoffset(self):
         '''Test time-zone given as an offset'''
+
+        # GMT
+        dt = DateTime('Tue, 10 Sep 2001 09:41:03 GMT')
+        self.assertEqual(dt.tzoffset(), 0)
+
+        # Timezone by name, a timezone that hasn't got daylightsaving.
+        dt = DateTime('Tue, 2 Mar 2001 09:41:03 GMT+3')
+        self.assertEqual(dt.tzoffset(), 10800)
+
+        # Timezone by name, has daylightsaving but is not in effect.
+        dt = DateTime('Tue, 21 Jan 2001 09:41:03 PST')
+        self.assertEqual(dt.tzoffset(), -28800)
+
+        # Timezone by name, with daylightsaving in effect
+        dt = DateTime('Tue, 24 Aug 2001 09:41:03 PST')
+        self.assertEqual(dt.tzoffset(), -25200)
+
+        # A negative numerical timezone
         dt = DateTime('Tue, 24 Jul 2001 09:41:03 -0400')
-        self.assertEqual(time.gmtime(dt.timeTime())[:6],
-                         (2001, 7, 24, 13, 41, 3))
+        self.assertEqual(dt.tzoffset(), -14400)
+        
+        # A positive numerical timzone
+        dt = DateTime('Tue, 6 Dec 1966 01:41:03 +0200')
+        self.assertEqual(dt.tzoffset(), 7200)
+        
+        # A negative numerical timezone with minutes.
+        dt = DateTime('Tue, 24 Jul 2001 09:41:03 -0637')
+        self.assertEqual(dt.tzoffset(), -23820)
+
+        # A positive numerical timezone with minutes.
+        dt = DateTime('Tue, 24 Jul 2001 09:41:03 +0425')
+        self.assertEqual(dt.tzoffset(), 15900)
+        
 
     def testISO8601(self):
         ''' iso 8601 dates '''