Beispiel #1
0
def _check_date_in_range(self, date):
    date = str_to_datetime(date)
    now = datetime.utcnow()
    lower = now - timedelta(minutes=TIMEDELTA)
    upper = now + timedelta(minutes=TIMEDELTA)
    if date < lower or date > upper:
        raise Invalid('Il valore non è compreso tra {} e {}'.format(
            lower, upper))
    return date
Beispiel #2
0
 def _check_date_not_expired(self, date):
     date = str_to_datetime(date)
     now = datetime.utcnow()
     if now >= date:
         raise Invalid('Richiesta scaduta in data {}'.format(date))
     return date