def from_datetime(value): try: value = validators.timedelta(value, allow_empty = True) return value except (ValueError, TypeError): pass return validators.datetime(value, allow_empty = True)
def is_datetime(value, minimum = None, maximum = None, coerce_value = False, **kwargs): """Indicate whether ``value`` is a :class:`datetime <python:datetime.datetime>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on or after this value. :type minimum: :class:`datetime <python:datetime.datetime>` / :class:`date <python:datetime.date>` / compliant :class:`str <python:str>` / :obj:`None <python:None>` :param maximum: If supplied, will make sure that ``value`` is on or before this value. :type maximum: :class:`datetime <python:datetime.datetime>` / :class:`date <python:datetime.date>` / compliant :class:`str <python:str>` / :obj:`None <python:None>` :param coerce_value: If ``True``, will return ``True`` if ``value`` can be coerced to a :class:`datetime <python:datetime.datetime>`. If ``False``, will only return ``True`` if ``value`` is a complete timestamp. Defaults to ``False``. :type coerce_value: :class:`bool <python:bool>` :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates keyword parameters passed to the underlying validator """ try: value = validators.datetime(value, minimum = minimum, maximum = maximum, coerce_value = coerce_value, **kwargs) except SyntaxError as error: raise error except Exception: return False return True
def from_datetime(value): if checkers.is_numeric(value): return from_timedelta(value) return validators.datetime(value, allow_empty=True)
def walk_updated(self, value): self._walk_updated = validators.datetime(value, allow_empty=True)
def from_datetime(value): return validators.datetime(value, allow_empty = True)