예제 #1
0
def is_datetime(instance):
    if not isinstance(instance, (binary_type, text_type)):
        return False

    if DATETIME_HAS_RFC3339_VALIDATOR:
        return validate_rfc3339(instance)

    if DATETIME_HAS_ISODATE:
        return isodate.parse_datetime(instance)

    return True
예제 #2
0
def is_datetime(instance):
    if not isinstance(instance, (bytes, str)):
        return False

    if DATETIME_HAS_RFC3339_VALIDATOR:
        return validate_rfc3339(instance)

    if DATETIME_HAS_STRICT_RFC3339:
        return strict_rfc3339.validate_rfc3339(instance)

    if DATETIME_HAS_ISODATE:
        return isodate.parse_datetime(instance)

    return True
예제 #3
0
 def is_datetime(instance):
     if not isinstance(instance, str):
         return True
     return validate_rfc3339(instance.upper())
예제 #4
0
def test_with_unicode(datetime_str):
    assert not validate_rfc3339(datetime_str)
예제 #5
0
def test_against_legacy(datetime_str):
    legacy_result = strict_rfc3339.validate_rfc3339(datetime_str)
    new_result = validate_rfc3339(datetime_str)
    assert legacy_result == new_result
예제 #6
0
def test_valid_dates(datetime_str):
    assert validate_rfc3339(datetime_str)
예제 #7
0
 def is_datetime(instance: object) -> bool:
     if not isinstance(instance, str):
         return True
     return validate_rfc3339(instance.upper())