def test_datetime(v):
    """Test for ISO datetime."""
    if not isinstance(v, string_types):
        return 0

    if len(v) > 22:
        # Not exactly correct; ISO8601 allows fractional seconds
        # which could result in a longer string.
        return 0

    if '-' not in v and ':' not in v:
        return 0

    for c in set(v):  # Set of Unique characters
        if not c.isdigit() and c not in 'T:-Z':
            return 0

    return 1
def test_datetime ( v ) : if not isinstance ( v , string_types ) : return 0 if len ( v ) > 22 : return 0 if '-' not in v and ':' not in v : return 0 for c in set ( v ) : if not c . isdigit ( ) and c not in 'T:-Z' : return 0 return 1
Test for ISO datetime.