What would be an elegant, efficient and Pythonic way to perform a h/m/s rounding operation on time related types in Python with control over the rounding resolution?
I use following code snippet to round to the next hour:
import datetime as dt tNow = dt.datetime.now() # round to the next full hour tNow -= dt.timedelta(minutes = tNow.minute, seconds = tNow.second, microseconds = tNow.microsecond) tNow += dt.timedelta(hours = 1)