Author belopolsky
Recipients SilentGhost, acucci, belopolsky, berker.peksag, cvrebert, ezio.melotti, gvanrossum, haypo, jerry.elmore, lemburg, martin.panter, matrixise, terry.reedy, tim.peters
Date 2016-03-01.21:35:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1456868147.03.0.641670124104.issue19475@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2016-03-01 21:35:47belopolskysetrecipients: + belopolsky, lemburg, gvanrossum, tim.peters, terry.reedy, haypo, ezio.melotti, cvrebert, SilentGhost, berker.peksag, martin.panter, matrixise, jerry.elmore, acucci
2016-03-01 21:35:47belopolskysetmessageid: <1456868147.03.0.641670124104.issue19475@psf.upfronthosting.co.za>
2016-03-01 21:35:47belopolskylinkissue19475 messages
2016-03-01 21:35:46belopolskycreate