Index: Doc/library/datetime.rst =================================================================== --- Doc/library/datetime.rst (revision 81998) +++ Doc/library/datetime.rst (working copy) @@ -1553,46 +1553,46 @@ .. class:: timezone(offset[, name]) - The ``offset`` argument must be specified as a :class:`timedelta` + The *offset* argument must be specified as a :class:`timedelta` object representing the difference between the local time and UTC. It must - be within the range [``-timedelta(hours=23, minutes=59), - ``timedelta(hours=23, minutes=59)``] and represent whole number of minutes, + be strictly between ``-timedelta(hours=24)`` and + ``timedelta(hours=24)`` and represent whole number of minutes, otherwise :exc:`ValueError` is raised. - The ``name`` argument is optional. If specified it must be a string that + The *name* argument is optional. If specified it must be a string that used as the value returned by the ``tzname(dt)`` method. Otherwise, ``tzname(dt)`` returns a string 'UTCsHH:MM', where s is the sign of - ``offset``, HH and MM are two digits of ``offset.hours`` and + *offset*, HH and MM are two digits of ``offset.hours`` and ``offset.minutes`` respectively. -.. method:: timezone.utcoffset(self, dt) +.. method:: timezone.utcoffset(dt) Returns the fixed value specified when the :class:`timezone` instance is - constructed. The ``dt`` argument is ignored. The return value is a + constructed. The *dt* argument is ignored. The return value is a :class:`timedelta` instance equal to the difference between the local time and UTC. -.. method:: timezone.tzname(self, dt) +.. method:: timezone.tzname(dt) Returns the fixed value specified when the :class:`timezone` instance is constructed or a string 'UTCsHH:MM', where s is the sign of - ``offset``, HH and MM are two digits of ``offset.hours`` and - ``offset.minutes`` respectively. The ``dt`` argument is ignored. + *offset*, HH and MM are two digits of ``offset.hours`` and + ``offset.minutes`` respectively. -.. method:: timezone.dst(self, dt) +.. method:: timezone.dst(dt) Always returns ``None``. -.. method:: timezone.fromutc(self, dt) +.. method:: timezone.fromutc(dt) - Returns ``dt + offset``. The ``dt`` argument must be aware with ``tzinfo`` + Returns ``dt + offset``. The *dt* argument must be aware with ``tzinfo`` set to ``self``. Class attributes: .. attribute:: timezone.utc - The UTC timezone, ``timezone(0, 'UTC')``. + The UTC timezone, ``timezone(timedelta(0))``. .. _strftime-strptime-behavior: Index: Lib/test/test_datetime.py =================================================================== --- Lib/test/test_datetime.py (revision 81998) +++ Lib/test/test_datetime.py (working copy) @@ -148,13 +148,13 @@ def test_class_members(self): limit = timedelta(hours=23, minutes=59) - self.assertEquals(timezone.utc.utcoffset(None), ZERO) - self.assertEquals(timezone.min.utcoffset(None), -limit) - self.assertEquals(timezone.max.utcoffset(None), limit) + self.assertEqual(timezone.utc.utcoffset(None), ZERO) + self.assertEqual(timezone.min.utcoffset(None), -limit) + self.assertEqual(timezone.max.utcoffset(None), limit) def test_constructor(self): - self.assertEquals(timezone.utc, timezone(timedelta(0))) + self.assertEqual(timezone.utc, timezone(timedelta(0))) # invalid offsets for invalid in [timedelta(microseconds=1), timedelta(1, 1), timedelta(seconds=1), timedelta(1), -timedelta(1)]: @@ -167,32 +167,32 @@ with self.assertRaises(TypeError): timezone(ZERO, 42) def test_inheritance(self): - self.assertTrue(isinstance(timezone.utc, tzinfo)) - self.assertTrue(isinstance(self.EST, tzinfo)) + self.assertIsInstance(timezone.utc, tzinfo) + self.assertIsInstance(self.EST, tzinfo) def test_utcoffset(self): dummy = self.DT for h in [0, 1.5, 12]: offset = h * HOUR - self.assertEquals(offset, timezone(offset).utcoffset(dummy)) - self.assertEquals(-offset, timezone(-offset).utcoffset(dummy)) + self.assertEqual(offset, timezone(offset).utcoffset(dummy)) + self.assertEqual(-offset, timezone(-offset).utcoffset(dummy)) with self.assertRaises(TypeError): self.EST.utcoffset('') with self.assertRaises(TypeError): self.EST.utcoffset(5) def test_dst(self): - self.assertEquals(None, timezone.utc.dst(self.DT)) + self.assertEqual(None, timezone.utc.dst(self.DT)) with self.assertRaises(TypeError): self.EST.dst('') with self.assertRaises(TypeError): self.EST.dst(5) def test_tzname(self): - self.assertEquals('UTC+00:00', timezone(ZERO).tzname(None)) - self.assertEquals('UTC-05:00', timezone(-5 * HOUR).tzname(None)) - self.assertEquals('UTC+09:30', timezone(9.5 * HOUR).tzname(None)) - self.assertEquals('UTC-00:01', timezone(timedelta(minutes=-1)).tzname(None)) - self.assertEquals('XYZ', timezone(-5 * HOUR, 'XYZ').tzname(None)) + self.assertEqual('UTC+00:00', timezone(ZERO).tzname(None)) + self.assertEqual('UTC-05:00', timezone(-5 * HOUR).tzname(None)) + self.assertEqual('UTC+09:30', timezone(9.5 * HOUR).tzname(None)) + self.assertEqual('UTC-00:01', timezone(timedelta(minutes=-1)).tzname(None)) + self.assertEqual('XYZ', timezone(-5 * HOUR, 'XYZ').tzname(None)) with self.assertRaises(TypeError): self.EST.tzname('') with self.assertRaises(TypeError): self.EST.tzname(5) @@ -203,8 +203,8 @@ for tz in [self.EST, self.ACDT, Eastern]: utctime = self.DT.replace(tzinfo=tz) local = tz.fromutc(utctime) - self.assertEquals(local - utctime, tz.utcoffset(local)) - self.assertEquals(local, + self.assertEqual(local - utctime, tz.utcoffset(local)) + self.assertEqual(local, self.DT.replace(tzinfo=timezone.utc)) def test_comparison(self): @@ -218,11 +218,11 @@ # test that timezone instances can be used by datetime t = datetime(1, 1, 1) for tz in [timezone.min, timezone.max, timezone.utc]: - self.assertEquals(tz.tzname(t), + self.assertEqual(tz.tzname(t), t.replace(tzinfo=tz).tzname()) - self.assertEquals(tz.utcoffset(t), + self.assertEqual(tz.utcoffset(t), t.replace(tzinfo=tz).utcoffset()) - self.assertEquals(tz.dst(t), + self.assertEqual(tz.dst(t), t.replace(tzinfo=tz).dst()) ############################################################################# @@ -1681,7 +1681,7 @@ def test_microsecond_rounding(self): # Test whether fromtimestamp "rounds up" floats that are less # than one microsecond smaller than an integer. - self.assertEquals(self.theclass.fromtimestamp(0.9999999), + self.assertEqual(self.theclass.fromtimestamp(0.9999999), self.theclass.fromtimestamp(1)) def test_insane_fromtimestamp(self): @@ -1710,7 +1710,7 @@ @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps") def test_negative_float_utcfromtimestamp(self): d = self.theclass.utcfromtimestamp(-1.05) - self.assertEquals(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000)) + self.assertEqual(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000)) def test_utcnow(self): import time Index: Modules/datetimemodule.c =================================================================== --- Modules/datetimemodule.c (revision 81998) +++ Modules/datetimemodule.c (working copy) @@ -3472,13 +3472,13 @@ static PyMethodDef timezone_methods[] = { {"tzname", (PyCFunction)timezone_tzname, METH_O, PyDoc_STR("If name is specified when timezone is created, returns the name." - " Otherwise returns offset as 'UTC(+|-)HHMM'.")}, + " Otherwise returns offset as 'UTC(+|-)HH:MM'.")}, {"utcoffset", (PyCFunction)timezone_utcoffset, METH_O, - PyDoc_STR("Returns fixed offset. Ignores its argument.")}, + PyDoc_STR("Returns fixed offset.")}, {"dst", (PyCFunction)timezone_dst, METH_O, - PyDoc_STR("Returns None. Ignores its argument.")}, + PyDoc_STR("Returns None.")}, {"fromutc", (PyCFunction)timezone_fromutc, METH_O, PyDoc_STR("datetime in UTC -> datetime in local time.")},