Paul Ganssle <p.gans...@gmail.com> added the comment:

@Barry I don't think it's a good idea to duplicate the `replace` functionality 
in `datetime` like that. I think the main problem isn't the `.replace`, it's 
the fact that you have to specify exactly which components you want to set to 
zero - to get "the beginning of this month" or "today at midnight" or "the 
beginning of the current hour" or "the beginning of the current minute", you 
have to manually replace a whole list of these components.

It doesn't help that `datetime.today()` leaks implementation details from 
`date.today()`, thus making it a slower, worse version of `datetime.now()`, 
since the overwhelmingly most common use cases for datetime rounding are 
probably "get today at midnight" and "get the current time with second 
precision". Still, I think a more general fix would be better now and in the 
future.

Even if we had "get today at midnight" and a `microseconds=0` argument to 
`datetime.now`, without a more general version of this, if (or possibly *when*) 
nanosecond precision is added to `datetime`, you'd now start having to add 
`microseconds=0, nanoseconds=0` or something to `datetime` (depending on the 
implementation of nanoseconds).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32522>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to