Only today/yesterday/last interval are valid datetime
171959
def get_result_group_names(self, request_datetime):
        """"""
        request_date = request_datetime.date()
        today = datetime.date.today()
        yesterday = datetime.date.today() - datetime.timedelta(days=1)
        result = []
        if total_seconds(datetime.datetime.now() - request_datetime) < REALTIME_UPDATE_INTERVAL:
            result.append('last_interval')
        if request_date == today:
            result.append(today.isoformat())
        elif request_date == yesterday:
            result.append(yesterday.isoformat())
        return result
296817
def check_time_param(t):
    """"""

    if type(t) is str:
        if not ISO.match(t):
            raise ValueError('Date string "%s" does not match ISO8601 format' %
                             (t))
        return t
    else:
        return t.isoformat()
1241723
def last_midnight():
    
    now = datetime.now()
    return datetime(now.year, now.month, now.day)
317166
def get_recent_mtime(t):
    '''
    '''
    if isinstance(t, int):
        # ignore micro seconds
        if len(str(t)) == 13:
            t = t // 1000
        t = datetime.datetime.fromtimestamp(t)
    now = datetime.datetime.now()
    delta = now - t
    if delta.days == 0:
        return datetime.datetime.strftime(t, '%H:%M:%S')
    elif now.year == t.year:
        return datetime.datetime.strftime(t, '%b %d')
    else:
        return datetime.datetime.strftime(t, '%b %d %Y')
643024
def _check_time_range(time_range, now):
    '''
    
    '''
    if _TIME_SUPPORTED:
        _start = dateutil_parser.parse(time_range['start'])
        _end = dateutil_parser.parse(time_range['end'])

        return bool(_start <= now <= _end)
    else:
        log.error('Dateutil is required.')
        return False
850017
def valid(self):
        """"""

        now = timezone.now()
        return self.filter(revoked=False, expires__gt=now, valid_from__lt=now)
523945
def valid_date(x: str) -> bool:
    
    try:
        if x != dt.datetime.strptime(x, DATE_FORMAT).strftime(DATE_FORMAT):
            raise ValueError
        return True
    except ValueError:
        return False
1205256
def last_update_time(self, value):
        
        if isinstance(value, (datetime.datetime,)):
            self._last_update_time = value
        else:
            raise ValueError("Expect last_update_time to be a datetime")
1202218
def GetDateRange(self):
    
    (minvalue, maxvalue, minorigin, maxorigin) = self.GetDateRangeWithOrigins()
    return (minvalue, maxvalue)
1088772
def _past_datetime_from(self):
        
        prevDt = self.__localBefore(timezone.localtime(), dt.time.max,
                                    excludeCancellations=True,
                                    excludeExtraInfo=True)
        return prevDt
636187
def yesterday(date=None):
    """"""
    if not date:
        return _date - datetime.timedelta(days=1)
    else:
        current_date = parse(date)
        return current_date - datetime.timedelta(days=1)
406485
def absdatetime(ts, default=None):
    """"""
    if ts is None:
        ts = default
    if isinstance(ts, dict):
        ts = timedelta(**ts)
    if isinstance(ts, timedelta):
        ts = now() + ts
    if isinstance(ts, datetime):
        return ts
    return None
473834
def last_datetime(self):
        """"""
        from datetime import datetime

        try:
            return datetime.fromtimestamp(self.state.lasttime)
        except TypeError:
            return None
1289938
def datetime_match(data, dts):
    
    dts = dts if islistable(dts) else [dts]
    if any([not isinstance(i, datetime.datetime) for i in dts]):
        error_msg = (
            "`time` can only be filtered by datetimes"
        )
        raise TypeError(error_msg)
    return data.isin(dts)
850550
def _interval(dates):
        """"""
        interval = (dates[1] - dates[0]).days
        last = dates[0]
        for dat in dates[1:]:
            if (dat - last).days != interval:
                return 0
            last = dat
        return interval
580784
def _validate_datetime_from_to(cls, start, end):
        
        if not start <= end:
            raise MlbAmBadParameter("not Start Day({start}) <= End Day({end})".format(start=start, end=end))
1087767
def calculateBestIntervals(self):
        """"""
        self.__intervals = []
        self.__readAPI(self.__getURL())
        today = datetime.datetime.now().date()

        self.__validInterval(datetime.date(2008, 1, 1), today)
        self.__logger.info("Total number of intervals: " +
                           str(len(self.__intervals)))
        self.__lastDay = today.strftime("%Y-%m-%d")