@@ -1071,16 +1071,20 @@ Instance methods:
1071
1071
1072
1072
If :attr: `.tzinfo ` is ``None ``, returns ``None ``, else returns
1073
1073
``self.tzinfo.utcoffset(self) ``, and raises an exception if the latter doesn't
1074
- return ``None ``, or a :class: `timedelta ` object representing a whole number of
1075
- minutes with magnitude less than one day.
1074
+ return ``None `` or a :class: `timedelta ` object with magnitude less than one day.
1075
+
1076
+ .. versionchanged :: 3.7
1077
+ The UTC offset is not restricted to a whole number of minutes.
1076
1078
1077
1079
1078
1080
.. method :: datetime.dst()
1079
1081
1080
1082
If :attr: `.tzinfo ` is ``None ``, returns ``None ``, else returns
1081
1083
``self.tzinfo.dst(self) ``, and raises an exception if the latter doesn't return
1082
- ``None ``, or a :class: `timedelta ` object representing a whole number of minutes
1083
- with magnitude less than one day.
1084
+ ``None `` or a :class: `timedelta ` object with magnitude less than one day.
1085
+
1086
+ .. versionchanged :: 3.7
1087
+ The DST offset is not restricted to a whole number of minutes.
1084
1088
1085
1089
1086
1090
.. method :: datetime.tzname()
@@ -1562,17 +1566,20 @@ Instance methods:
1562
1566
1563
1567
If :attr: `.tzinfo ` is ``None ``, returns ``None ``, else returns
1564
1568
``self.tzinfo.utcoffset(None) ``, and raises an exception if the latter doesn't
1565
- return ``None `` or a :class: `timedelta ` object representing a whole number of
1566
- minutes with magnitude less than one day.
1569
+ return ``None `` or a :class: `timedelta ` object with magnitude less than one day.
1570
+
1571
+ .. versionchanged :: 3.7
1572
+ The UTC offset is not restricted to a whole number of minutes.
1567
1573
1568
1574
1569
1575
.. method :: time.dst()
1570
1576
1571
1577
If :attr: `.tzinfo ` is ``None ``, returns ``None ``, else returns
1572
1578
``self.tzinfo.dst(None) ``, and raises an exception if the latter doesn't return
1573
- ``None ``, or a :class: `timedelta ` object representing a whole number of minutes
1574
- with magnitude less than one day.
1579
+ ``None ``, or a :class: `timedelta ` object with magnitude less than one day.
1575
1580
1581
+ .. versionchanged :: 3.7
1582
+ The DST offset is not restricted to a whole number of minutes.
1576
1583
1577
1584
.. method :: time.tzname()
1578
1585
@@ -1641,13 +1648,14 @@ Example:
1641
1648
1642
1649
.. method :: tzinfo.utcoffset(dt)
1643
1650
1644
- Return offset of local time from UTC, in minutes east of UTC. If local time is
1651
+ Return offset of local time from UTC, as a :class: `timedelta ` object that is
1652
+ positive east of UTC. If local time is
1645
1653
west of UTC, this should be negative. Note that this is intended to be the
1646
1654
total offset from UTC; for example, if a :class: `tzinfo ` object represents both
1647
1655
time zone and DST adjustments, :meth: `utcoffset ` should return their sum. If
1648
1656
the UTC offset isn't known, return ``None ``. Else the value returned must be a
1649
- :class: `timedelta ` object specifying a whole number of minutes in the range
1650
- -1439 to 1439 inclusive (1440 = 24 \* 60; the magnitude of the offset must be less
1657
+ :class: `timedelta ` object strictly between `` -timedelta(hours=24) `` and
1658
+ `` timedelta(hours=24) `` ( the magnitude of the offset must be less
1651
1659
than one day). Most implementations of :meth: `utcoffset ` will probably look
1652
1660
like one of these two::
1653
1661
@@ -1660,10 +1668,14 @@ Example:
1660
1668
The default implementation of :meth: `utcoffset ` raises
1661
1669
:exc: `NotImplementedError `.
1662
1670
1671
+ .. versionchanged :: 3.7
1672
+ The UTC offset is not restricted to a whole number of minutes.
1673
+
1663
1674
1664
1675
.. method :: tzinfo.dst(dt)
1665
1676
1666
- Return the daylight saving time (DST) adjustment, in minutes east of UTC, or
1677
+ Return the daylight saving time (DST) adjustment, as a :class: `timedelta `
1678
+ object or
1667
1679
``None `` if DST information isn't known. Return ``timedelta(0) `` if DST is not
1668
1680
in effect. If DST is in effect, return the offset as a :class: `timedelta ` object
1669
1681
(see :meth: `utcoffset ` for details). Note that DST offset, if applicable, has
@@ -1708,6 +1720,9 @@ Example:
1708
1720
1709
1721
The default implementation of :meth: `dst ` raises :exc: `NotImplementedError `.
1710
1722
1723
+ .. versionchanged :: 3.7
1724
+ The DST offset is not restricted to a whole number of minutes.
1725
+
1711
1726
1712
1727
.. method :: tzinfo.tzname(dt)
1713
1728
@@ -1887,21 +1902,27 @@ made to civil time.
1887
1902
The *offset * argument must be specified as a :class: `timedelta `
1888
1903
object representing the difference between the local time and UTC. It must
1889
1904
be strictly between ``-timedelta(hours=24) `` and
1890
- ``timedelta(hours=24) `` and represent a whole number of minutes,
1891
- otherwise :exc: `ValueError ` is raised.
1905
+ ``timedelta(hours=24) ``, otherwise :exc: `ValueError ` is raised.
1892
1906
1893
1907
The *name * argument is optional. If specified it must be a string that
1894
1908
will be used as the value returned by the :meth: `datetime.tzname ` method.
1895
1909
1896
1910
.. versionadded :: 3.2
1897
1911
1912
+ .. versionchanged :: 3.7
1913
+ The UTC offset is not restricted to a whole number of minutes.
1914
+
1915
+
1898
1916
.. method :: timezone.utcoffset(dt)
1899
1917
1900
1918
Return the fixed value specified when the :class: `timezone ` instance is
1901
1919
constructed. The *dt * argument is ignored. The return value is a
1902
1920
:class: `timedelta ` instance equal to the difference between the
1903
1921
local time and UTC.
1904
1922
1923
+ .. versionchanged :: 3.7
1924
+ The UTC offset is not restricted to a whole number of minutes.
1925
+
1905
1926
.. method :: timezone.tzname(dt)
1906
1927
1907
1928
Return the fixed value specified when the :class: `timezone ` instance
@@ -2025,8 +2046,8 @@ format codes.
2025
2046
| | number, zero-padded on the | 999999 | |
2026
2047
| | left. | | |
2027
2048
+-----------+--------------------------------+------------------------+-------+
2028
- | ``%z `` | UTC offset in the form +HHMM | (empty), +0000, -0400, | \( 6) |
2029
- | | or - HHMM (empty string if the | +1030 | |
2049
+ | ``%z `` | UTC offset in the form | (empty), +0000, -0400, | \( 6) |
2050
+ | | ± HHMM[SS] (empty string if the | +1030 | |
2030
2051
| | object is naive). | | |
2031
2052
+-----------+--------------------------------+------------------------+-------+
2032
2053
| ``%Z `` | Time zone name (empty string | (empty), UTC, EST, CST | |
@@ -2139,12 +2160,19 @@ Notes:
2139
2160
For an aware object:
2140
2161
2141
2162
``%z ``
2142
- :meth: `utcoffset ` is transformed into a 5-character string of the form
2143
- + HHMM or -HHMM , where HH is a 2-digit string giving the number of UTC
2163
+ :meth: `utcoffset ` is transformed into a string of the form
2164
+ ± HHMM[SS[.uuuuuu]] , where HH is a 2-digit string giving the number of UTC
2144
2165
offset hours, and MM is a 2-digit string giving the number of UTC offset
2145
- minutes. For example, if :meth: `utcoffset ` returns
2146
- ``timedelta(hours=-3, minutes=-30) ``, ``%z `` is replaced with the string
2147
- ``'-0330' ``.
2166
+ minutes, SS is a 2-digit string string giving the number of UTC offset
2167
+ seconds and uuuuuu is a 2-digit string string giving the number of UTC
2168
+ offset microseconds. The uuuuuu part is omitted when the offset is a
2169
+ whole number of minutes and both the uuuuuu and the SS parts are omitted
2170
+ when the offset is a whole number of minutes. For example, if
2171
+ :meth: `utcoffset ` returns ``timedelta(hours=-3, minutes=-30) ``, ``%z `` is
2172
+ replaced with the string ``'-0330' ``.
2173
+
2174
+ .. versionchanged :: 3.7
2175
+ The UTC offset is not restricted to a whole number of minutes.
2148
2176
2149
2177
``%Z ``
2150
2178
If :meth: `tzname ` returns ``None ``, ``%Z `` is replaced by an empty
0 commit comments