#NEWLINE# def find_x_times( start_dt , unit , step ) : #NEWLINE# #INDENT# if ( unit == SEC ) : #NEWLINE# #INDENT# dt = start_dt . replace ( second = ( start_dt . second - ( start_dt . second % step ) ) ) #NEWLINE# x_delta = timedelta ( seconds = step ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( unit == MIN ) : #NEWLINE# #INDENT# dt = start_dt . replace ( second = 0 , minute = ( start_dt . minute - ( start_dt . minute % step ) ) ) #NEWLINE# x_delta = timedelta ( minutes = step ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( unit == HOUR ) : #NEWLINE# #INDENT# dt = start_dt . replace ( second = 0 , minute = 0 , hour = ( start_dt . hour - ( start_dt . hour % step ) ) ) #NEWLINE# x_delta = timedelta ( hours = step ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( unit == DAY ) : #NEWLINE# #INDENT# dt = start_dt . replace ( second = 0 , minute = 0 , hour = 0 ) #NEWLINE# x_delta = timedelta ( days = step ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'Invalid unit: %s' % unit ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# while ( dt < start_dt ) : #NEWLINE# #INDENT# dt += x_delta #NEWLINE# #UNINDENT# return ( dt , x_delta )