def historical_limit_date(self): """get historical_limit_date (90 days)""" historical_limit = settings.historical_limit() temp = (datetime.datetime.now() - datetime.timedelta(days=historical_limit)) date = temp.strftime('%Y-%m-%d') return date
def validate_time_range(date): """validate time range""" date_parsed = dateutil.parser.parse(date) if date_parsed.tzinfo is None: date_parsed = pytz.utc.localize(date_parsed) time_range = (datetime.datetime.utcnow().replace(tzinfo=pytz.utc) - datetime.timedelta(days=settings.historical_limit())) if date_parsed < time_range: raise ValueError(date + " is out of range")