Skip to content

Commit

Permalink
bpo-31327: Update time documentation to reflect possible errors (pyth…
Browse files Browse the repository at this point in the history
…onGH-31460)

As per the comments, this mirrors the [datetime documentation](https://docs.python.org/3/library/datetime.htmlGH-datetime.datetime.fromtimestamp).

```
>>> import time
>>> time.localtime(999999999999999999999)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: timestamp out of range for platform time_t
>>> time.localtime(-3600)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument
```
(cherry picked from commit c83fc9c)

Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
  • Loading branch information
slateny authored and miss-islington committed Mar 11, 2022
1 parent 3bc8019 commit 55a96d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Doc/library/time.rst
Expand Up @@ -259,6 +259,12 @@ Functions
:const:`None`, the current time as returned by :func:`.time` is used. The dst
flag is set to ``1`` when DST applies to the given time.

:func:`localtime` may raise :exc:`OverflowError`, if the timestamp is
outside the range of values supported by the platform C :c:func:`localtime`
or :c:func:`gmtime` functions, and :exc:`OSError` on :c:func:`localtime` or
:c:func:`gmtime` failure. It's common for this to be restricted to years
between 1970 and 2038.


.. function:: mktime(t)

Expand Down

0 comments on commit 55a96d6

Please sign in to comment.