diff -r 16350c1f81a1 Doc/library/datetime.rst --- a/Doc/library/datetime.rst Sun Dec 04 10:22:36 2016 +0200 +++ b/Doc/library/datetime.rst Sun Dec 04 10:46:14 2016 +0100 @@ -1221,7 +1221,7 @@ >>> from datetime import datetime - >>> datetime.now().isoformat(timespec='minutes') + >>> datetime.now().isoformat(timespec='minutes') # doctest: +SKIP '2002-12-25T00:00' >>> dt = datetime(2015, 1, 1, 12, 30, 59, 0) >>> dt.isoformat(timespec='microseconds') @@ -1368,8 +1368,8 @@ .. _datetime-time: -:class:`.time` Objects ----------------------- +:class:`time` Objects +--------------------- A time object represents a (local) time of day, independent of any particular day, and subject to adjustment via a :class:`tzinfo` object. @@ -1466,7 +1466,7 @@ ``!=``. The latter cases return :const:`False` or :const:`True`, respectively. .. versionchanged:: 3.3 - Equality comparisons between naive and aware :class:`~datetime.time` instances + Equality comparisons between naive and aware :class:`time` instances don't raise :exc:`TypeError`. * hash, use as dict key @@ -1781,9 +1781,11 @@ else: return dt -Example :class:`tzinfo` classes: - -.. literalinclude:: ../includes/tzinfo-examples.py +In the following :download:`tzinfo_example.py +<../includes/tzinfo_examples.py>` file there are some examples of +:class:`tzinfo` classes: + +.. literalinclude:: ../includes/tzinfo_examples.py Note that there are unavoidable subtleties twice per year in a :class:`tzinfo` subclass accounting for both standard and daylight time, at the DST transition @@ -1802,8 +1804,12 @@ When DST starts (the "start" line), the local wall clock leaps from 1:59 to 3:00. A wall time of the form 2:MM doesn't really make sense on that day, so ``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST -begins. For example, at the Spring forward transition of 2016, we get - +begins. For example, at the Spring forward transition of 2016, we get: + +.. doctest:: astimezone + + >>> from datetime import datetime, timezone + >>> from tzinfo_examples import HOUR, Eastern >>> u0 = datetime(2016, 3, 13, 5, tzinfo=timezone.utc) >>> for i in range(4): ... u = u0 + i*HOUR @@ -1825,7 +1831,9 @@ hours into the same local hour then. In the Eastern example, UTC times of the form 5:MM and 6:MM both map to 1:MM when converted to Eastern, but earlier times have the :attr:`~datetime.fold` attribute set to 0 and the later times have it set to 1. -For example, at the Fall back transition of 2016, we get +For example, at the Fall back transition of 2016, we get: + +.. doctest:: astimezone >>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc) >>> for i in range(4):