discard = datetime.timedelta(minutes=tm.minute % 10, seconds=tm.second,
    microseconds=tm.microsecond)
tm -= discard
if discard >= datetime.timedelta(minutes=5):
    tm += datetime.timedelta(minutes=10)
How to round the minute of a datetime object python