Source:
import datetime
import math

def time_round_up(tm, round_min=10):
    min_up = math.ceil(float(tm.minute) / round_min) * round_min
    min_left = min_up  - tm.minute
    rounded_time = tm + datetime.timedelta(minutes=min_left)
    rounded_time = rounded_time.replace(second=0).replace(microsecond=0)
    return rounded_time

Rounds up a time to the nearest minute passed.

Pythoneer 6 years ago