[New-bugs-announce] [issue32195] datetime.strftime with %Y no longer outputs leading zeros

Dave Challis report at bugs.python.org
Fri Dec 1 09:39:29 EST 2017


New submission from Dave Challis <suicas at gmail.com>:

Tested in python 3.6.2:

    >>> import datetime
    >>> datetime.datetime.min.strftime('%Y')
    '1'

Expected output:

    '0001'

This means that strftime and strptime aren't necessarily symmetric, e.g.:

    >>> datetime.datetime.strptime(datetime.datetime.min.strftime('%Y'), '%Y')
    ValueError: time data '1' does not match format '%Y'

----------
components: Library (Lib)
messages: 307389
nosy: davechallis
priority: normal
severity: normal
status: open
title: datetime.strftime with %Y no longer outputs leading zeros
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32195>
_______________________________________


More information about the New-bugs-announce mailing list