Alexander Belopolsky added the comment:

I hope my prediction "I am afraid that the rounding issues may kill this 
proposal" (see msg202276) will not come true.

I think the correct way to view "timespec" is a way to suppress/enforce 
printing of trailing digits.

Users that choose printing less than full usec format should make sure that 
their datetime instances are properly rounded before printing.

Unfortunately, I does not look like the datetime module makes rounding easy.  
The best I can think of is something like

def round_datetime(dt, delta):
    dt0 = datetime.combine(dt.date(), time(0))
    return dt0 + round((dt - dt0) / delta) * delta

Maybe a datetime.round() method along these lines will be a worthwhile addition?

----------

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

Reply via email to