New submission from Paul Ganssle <[email protected]>:
One thing I think that is fairly common is the desire to get the current
datetime only up to a current precision, so you see a lot of things in, say,
`dateutil` like this:
dt = datetime.now().replace(hours=0, minutes=0, seconds=0, microseconds=0)
Or:
dt = datetime.now().replace(microseconds=0)
I think it would make sense to add a `precision` keyword argument, similar to
the `timespec` argument to isoformat
(https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat),
then you could just do:
dt = datetime.now(precision='day')
And get the current date as a datetime.
----------
components: Library (Lib)
messages: 309703
nosy: belopolsky, p-ganssle, tim.peters
priority: normal
severity: normal
status: open
title: Add precision argument to datetime.now
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32522>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com