[New-bugs-announce] [issue38082] datetime.time object incorrectly shows associated date in strftime() output

Abhisek Maiti report at bugs.python.org
Tue Sep 10 03:03:53 EDT 2019


New submission from Abhisek Maiti <mail2abhisek.maiti at gmail.com>:

`
from datetime import time

t = time(13, 5, 45)
`
While `t.year`, `t.month` and `t.day` results into `AttributeError` the following:
`
t.strftime('%Y : %B : %d - %H : %M : %S')
`
generates:

`
1900 : January : 01 - 13 : 05 : 45
`
This is unexpected behavior since `datetime.time` object does not have those attributes. The documentation at https://docs.python.org/3/library/datetime.html specifically states that 

"
class datetime.time

    An idealized time, independent of any particular day, assuming that every day has exactly 24*60*60 seconds (there is no notion of “leap seconds” here). Attributes: hour, minute, second, microsecond, and tzinfo.
"

----------
components: Library (Lib)
messages: 351580
nosy: Abhisek Maiti
priority: normal
severity: normal
status: open
title: datetime.time object incorrectly shows associated date in strftime() output
type: behavior
versions: Python 3.7

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


More information about the New-bugs-announce mailing list