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?
My guess is that it would require a time modulo operation. Illustrative examples:
Relevant time related types I can think of:
datetime.datetime
\ datetime.time
struct_time
For a datetime.datetime rounding, see this function: https://stackoverflow.com/a/10854034/1431079
Sample of use:
print roundTime(datetime.datetime(2012,12,31,23,44,59,1234),roundTo=60*60)
2013-01-01 00:00:00