[issue13305] datetime.strftime("%Y") not consistent for years < 1000

STINNER Victor report at bugs.python.org
Fri Mar 11 16:43:52 EST 2016


STINNER Victor added the comment:

acucci's patch doc.patch suggests to use format "%4Y". Problem: I tried it on Linux, and it looks like it doesn't work.

>>> datetime.datetime.strptime("1980", "%Y")
datetime.datetime(1980, 1, 1, 0, 0)
>>> datetime.datetime.strptime("1980", "%4Y")
Traceback (most recent call last):
  ...
ValueError: '4' is a bad directive in format '%4Y'

Or maybe I misunderstood the doc change. Do you suggest to use %4Y format with strptime(), with strftime() or with both?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13305>
_______________________________________


More information about the Python-bugs-list mailing list