This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: datetime documentation contradictory on leap second support
Type: enhancement Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: wolever Nosy List: belopolsky, ezio.melotti, python-dev, wolever
Priority: normal Keywords:

Created on 2013-08-12 20:29 by wolever, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg195008 - (view) Author: David Wolever (wolever) * (Python committer) Date: 2013-08-12 20:29
The documentation for the `%S` formatter suggests that it supports leap seconds, but the footnote contradicts that:

> The range really is 0 to 61; according to the Posix standard this
> accounts for leap seconds and the (very rare) double leap seconds.
> The time module may produce and does accept leap seconds since it is
> based on the Posix standard, but the datetime module does not accept
> leap seconds in strptime() input nor will it produce them in
> strftime() output.

I propose that the documentation be updated to mirror the 3.X documentation: no leap second in the example and a footnote which makes note of that and suggests using the time module.
msg195017 - (view) Author: David Wolever (wolever) * (Python committer) Date: 2013-08-12 21:09
Here's the relevant diff. Will commit on a +1.

diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -1664,7 +1664,7 @@
 | ``%M``    | Minute as a zero-padded        | 00, 01, ..., 59        |       |
 |           | decimal number.                |                        |       |
 +-----------+--------------------------------+------------------------+-------+
-| ``%S``    | Second as a zero-padded        | 00, 01, ..., 61        | \(3)  |
+| ``%S``    | Second as a zero-padded        | 00, 01, ..., 59        | \(3)  |
 |           | decimal number.                |                        |       |
 +-----------+--------------------------------+------------------------+-------+
 | ``%f``    | Microsecond as a decimal       | 000000, 000001, ...,   | \(4)  |
@@ -1728,12 +1728,8 @@
    the output hour field if the ``%I`` directive is used to parse the hour.
 
 (3)
-   The range really is ``0`` to ``61``; according to the Posix standard this
-   accounts for leap seconds and the (very rare) double leap seconds.
-   The :mod:`time` module may produce and does accept leap seconds since
-   it is based on the Posix standard, but the :mod:`datetime` module
-   does not accept leap seconds in :meth:`strptime` input nor will it
-   produce them in :func:`strftime` output.
+   Unlike the :mod:`time` module, the :mod:`datetime` module does not support
+   leap seconds.
 
 (4)
    ``%f`` is an extension to the set of format characters in the C standard
msg195096 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2013-08-13 20:51
+1

:-)
msg195191 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-14 18:35
New changeset 5063dab96843 by David Wolever in branch '2.7':
Issue #18718: datetime documentation contradictory on leap second support
http://hg.python.org/cpython/rev/5063dab96843
msg195408 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-08-16 20:15
Can this be closed?
msg195409 - (view) Author: David Wolever (wolever) * (Python committer) Date: 2013-08-16 20:16
D'oh, yes, it can (and I've closed it now).
History
Date User Action Args
2022-04-11 14:57:49adminsetgithub: 62918
2013-08-16 20:16:47woleversetstatus: pending -> closed

messages: + msg195409
2013-08-16 20:15:48ezio.melottisetstatus: open -> pending

type: enhancement

nosy: + ezio.melotti
messages: + msg195408
resolution: fixed
stage: resolved
2013-08-14 18:35:40python-devsetnosy: + python-dev
messages: + msg195191
2013-08-13 20:51:30belopolskysetnosy: + belopolsky
messages: + msg195096
2013-08-12 21:09:34woleversetmessages: + msg195017
2013-08-12 20:29:36wolevercreate