Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f1dae31

Browse files
committed
Clarify what changed with respect to date ranges and two-digit years.
1 parent 305bc9e commit f1dae31

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

Doc/whatsnew/3.2.rst

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,7 @@ Some smaller changes made to the core Python language are:
489489
original object.
490490

491491
>>> with memoryview(b'abcdefgh') as v:
492-
... print(v.tolist())
493-
...
492+
print(v.tolist())
494493
[97, 98, 99, 100, 101, 102, 103, 104]
495494

496495
(Added by Antoine Pitrou; :issue:`9757`.)
@@ -934,20 +933,28 @@ datetime and time
934933
* The :meth:`datetime.date.strftime` method is no longer restricted to years
935934
after 1900. The new supported year range is from 1000 to 9999 inclusive.
936935

937-
* The rules for two-digit years in time tuples have changed. Now, the
938-
:func:`time.asctime`, :func:`time.strftime` and :func:`time.mktime`
939-
functions will accept any two- or four-digit year when
940-
:attr:`time.accept2dyear` is true. Two-digit years are converted to
941-
four-digits using the same heuristics as before, but a deprecation
942-
warning will be issued whenever such conversion occurs.
943-
944-
* The :func:`time.asctime`, :func:`time.mktime`, and
945-
:func:`time.strftime` functions are no longer restricted to years
946-
after 1900. Now, when :attr:`time.accept2dyear` is false, the
947-
:func:`time.asctime` function will accept any year that fits in
948-
a C int, while :func:`time.mktime` and :func:`time.strftime`
949-
functions will accept full range supported by the corresponding
950-
operating system functions.
936+
* Whenever a two-digit year is used in a time tuple, the interpretation has been
937+
governed by :attr:`time.accept2dyear`. The default is *True* which means that
938+
for a two-digit year, the century is guessed according to the POSIX rules
939+
governing the ``%y`` strptime format.
940+
941+
Starting with Py3.2, use of the century guessing heuristic will emit a
942+
:exc:`DeprecationWarning`. Instead, it is recommended that
943+
:attr:`time.accept2dyear` be set to *False* so that large date ranges
944+
can be used without guesswork:
945+
946+
>>> time.accept2dyear = 1 # guess whether 11 means 11 or 2011
947+
>>> time.asctime((11, 1, 1, 12, 34, 56, 4, 1, 0))
948+
'Fri Jan 1 12:34:56 2011'
949+
>>> time.accept2dyear = 0 # use the full range of allowable dates
950+
>>> time.asctime((11, 1, 1, 12, 34, 56, 4, 1, 0))
951+
'Fri Jan 1 12:34:56 11'
952+
953+
Several functions now have significantly expanded date ranges. When
954+
:attr:`time.accept2dyear` is false, the :func:`time.asctime` function will
955+
accept any year that fits in a C int, while the :func:`time.mktime` and
956+
:func:`time.strftime` functions will accept the full range supported by the
957+
corresponding operating system functions.
951958

952959
(Contributed by Alexander Belopolsky and Victor Stinner.)
953960

0 commit comments

Comments
 (0)