def get_time_range(time_str, interval): """ Returns pair of RichDateTime. """ d = timedelta(minutes=interval) if time_str: # parse string as localtime t = RichDateTime.strptime(time_str, '%Y%m%d%H%M') else: # get current time in localtime t = RichDateTime.from_datetime((RichDateTime.now() % d) - d) return t, RichDateTime.from_datetime(t + d)
def f(datapoint): # read timestamp as local time t = RichDateTime.from_datetime(datapoint['Timestamp'], tzlocal()) return metric, statistics, datapoint[statistics], t