Ceil a datetime to next quarter of an hour
This one takes microseconds into account! import math def ceil_dt(dt): # how many secs have passed this hour nsecs = dt.minute*60 + dt.second + dt.microsecond*1e-6 # number of seconds to next quarter hour mark # Non-analytic (brute force is fun) way: # delta = next(x for x in xrange(0,3601,900) if x>=nsecs) – nsecs # analytic … Read more