def get_time_points(interval, start_time=None, stop_time=None):
 def truncate_datetime(dt):
  dt = dt.replace(minute=0, second=0, microsecond=0)
  if (interval in ('day', 'month')):
   dt = dt.replace(hour=0)
  if (interval == 'month'):
   dt = dt.replace(day=1)
  return dt
 if (start_time and stop_time):
  (start_time, stop_time) = sorted([start_time, stop_time])
  stop_time = truncate_datetime(stop_time)
 else:
  stop_time = datetime.datetime.utcnow()
  stop_time = truncate_datetime(stop_time)
  range = time_range_by_interval[interval]
  start_time = (stop_time - range)
 step = timedelta_by_name(interval)
 current_time = stop_time
 time_points = []
 while (current_time >= start_time):
  time_points.append(current_time)
  if (interval != 'month'):
   current_time -= step
  else:
   current_time = decrement_month(current_time)
 return time_points

def get_time_points ( interval , start_time = None , stop_time = None ) : def truncate_datetime ( dt ) : dt = dt . replace ( minute = 0 , second = 0 , microsecond = 0 ) if ( interval in ( 'day' , 'month' ) ) : dt = dt . replace ( hour = 0 ) if ( interval == 'month' ) : dt = dt . replace ( day = 1 ) return dt if ( start_time and stop_time ) : ( start_time , stop_time ) = sorted ( [ start_time , stop_time ] ) stop_time = truncate_datetime ( stop_time ) else : stop_time = datetime . datetime . utcnow ( ) stop_time = truncate_datetime ( stop_time ) range = time_range_by_interval [ interval ] start_time = ( stop_time - range ) step = timedelta_by_name ( interval ) current_time = stop_time time_points = [ ] while ( current_time >= start_time ) : time_points . append ( current_time ) if ( interval != 'month' ) : current_time -= step else : current_time = decrement_month ( current_time ) return time_points
return time points for given interval type .