How to use the aniso8601.parse_date function in aniso8601

To help you get started, we’ve selected a few aniso8601 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ButterFlyDevs / StudentsManagementSystem / microservice2Unused / example_app / flask_restful / inputs.py View on Github external
def _parse_interval(value):
    """Do some nasty try/except voodoo to get some sort of datetime
    object(s) out of the string.
    """
    try:
        return sorted(aniso8601.parse_interval(value))
    except ValueError:
        try:
            return aniso8601.parse_datetime(value), None
        except ValueError:
            return aniso8601.parse_date(value), None
github biosustain / potion / flask_potion / fields.py View on Github external
def converter(self, value):
        return aniso8601.parse_date(value)
github johnwheeler / flask-ask / samples / tidepooler / tidepooler.py View on Github external
def dialog_tide(city, date):
    if city is not None:
        if city.lower() not in STATIONS:
            return supported_cities()
        if SESSION_DATE not in session.attributes:
            session.attributes[SESSION_CITY] = city
            return _dialog_date(city)
        date = aniso8601.parse_date(session.attributes[SESSION_DATE])
        return _make_tide_request(city, date)
    elif date is not None:
        if SESSION_CITY not in session.attributes:
            session.attributes[SESSION_DATE] = date.isoformat()
            return _dialog_city(date)
        city = session.attributes[SESSION_CITY]
        return _make_tide_request(city, date)
    else:
        return _dialog_no_slot()
github flask-restful / flask-restful / flask_restful / inputs.py View on Github external
def _parse_interval(value):
    """Do some nasty try/except voodoo to get some sort of datetime
    object(s) out of the string.
    """
    try:
        return sorted(aniso8601.parse_interval(value))
    except ValueError:
        try:
            return aniso8601.parse_datetime(value), None
        except ValueError:
            return aniso8601.parse_date(value), None
github jgbustos / ml_rest_api / ml_rest_api / api / model / predict.py View on Github external
"int": fields.Integer,
        "float": fields.Float,
        "bool": fields.Boolean,
        "datetime": fields.DateTime,
        "date": fields.Date,
    }
    model_dict: Dict = {}
    model_sample: Dict = trained_model_wrapper.sample()
    if model_sample:
        for key, value in model_sample.items():
            fields_class: fields.Raw = fields_classes_map.get(
                type(value).__name__, fields.String
            )
            if type(value).__name__ == "str":
                try:
                    parse_date(value)
                    fields_class = fields.Date
                except ValueError:
                    pass
                try:
                    parse_datetime(value)
                    fields_class = fields.DateTime
                except ValueError:
                    pass
            model_dict[key] = fields_class(example=value, readonly=True, required=True)
    return api.model("input_vector", model_dict)
github modesty / calllog211 / lib / flask_restful / inputs.py View on Github external
def _parse_interval(value):
    """Do some nasty try/except voodoo to get some sort of datetime
    object(s) out of the string.
    """
    try:
        return sorted(aniso8601.parse_interval(value))
    except ValueError:
        try:
            return aniso8601.parse_datetime(value), None
        except ValueError:
            return aniso8601.parse_date(value), None
github noirbizarre / flask-restplus / flask_restplus / inputs.py View on Github external
def _parse_interval(value):
    '''
    Do some nasty try/except voodoo to get some sort of datetime
    object(s) out of the string.
    '''
    try:
        return sorted(aniso8601.parse_interval(value))
    except ValueError:
        try:
            return aniso8601.parse_datetime(value), None
        except ValueError:
            return aniso8601.parse_date(value), None
github noirbizarre / flask-restplus / flask_restplus / inputs.py View on Github external
Example::

        inputs.datetime_from_iso8601("2012-01-01T23:30:00+02:00")

    :param str value: The ISO8601-complying string to transform
    :return: A datetime
    :rtype: datetime
    :raises ValueError: if value is an invalid date literal

    '''
    try:
        try:
            return aniso8601.parse_datetime(value)
        except ValueError:
            date = aniso8601.parse_date(value)
            return datetime(date.year, date.month, date.day)
    except Exception:
        raise ValueError('Invalid date literal "{0}"'.format(value))
github graphql-python / graphene / graphene / types / datetime.py View on Github external
def parse_value(value):
        try:
            if isinstance(value, datetime.date):
                return value
            elif isinstance(value, string_types):
                return parse_date(value)
        except ValueError:
            return None