r"""
    Args:
        datetime_str (str):

    Returns:
        str:

    References:
        https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

    CommandLine:
        python -m utool.util_time --exec-determine_timestamp_format

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> import utool as ut
        >>> datetime_str_list = [
        >>>     '0000:00:00 00:00:00',
        >>>     '    :  :     :  :  ',
        >>>     '2015:04:01 00:00:00',
        >>>     '2080/04/01 00:00:00',
        >>>     '2005-10-27T14:35:20+02:00',
        >>>     '6:35:01\x002006:03:19 1',
        >>>     '2016/05/03 16:34:57 EST'
        >>> ]
        >>> result = ut.repr4([determine_timestamp_format(datetime_str)
        >>>            for datetime_str in datetime_str_list])
        >>> print(result)

def determine_timestamp_format(datetime_str, warn=True):
    r"""
    Args:
        datetime_str (str):

    Returns:
        str:

    References:
        https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

    CommandLine:
        python -m utool.util_time --exec-determine_timestamp_format

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> import utool as ut
        >>> datetime_str_list = [
        >>>     '0000:00:00 00:00:00',
        >>>     '    :  :     :  :  ',
        >>>     '2015:04:01 00:00:00',
        >>>     '2080/04/01 00:00:00',
        >>>     '2005-10-27T14:35:20+02:00',
        >>>     '6:35:01\x002006:03:19 1',
        >>>     '2016/05/03 16:34:57 EST'
        >>> ]
        >>> result = ut.repr4([determine_timestamp_format(datetime_str)
        >>>            for datetime_str in datetime_str_list])
        >>> print(result)
    """
    import re
    # try to determine the format
    clean_datetime_str = datetime_str.replace('\x00', ' ').strip(';').strip()
    if len(clean_datetime_str) == 25 and 'T' in clean_datetime_str:
        # Delete last colon from ISO 8601 format
        # clean_datetime_str = clean_datetime_str[:-3] + clean_datetime_str[-2:]
        if True or six.PY2:
            if warn:
                print('WARNING: Python 2.7 does not support %z directive '
                      'in strptime, ignoring timezone in parsing: ' +
                      clean_datetime_str)
            clean_datetime_str = clean_datetime_str[:-6]

    year_regex  = r'(\d\d)?\d\d'
    month_regex = '[0-1]?[0-9]'
    day_regex   = '[0-3]?[0-9]'

    time_regex = r'[0-6]?[0-9]:[0-6]?[0-9]:[0-6]?[0-9]'

    #odd_time_regex = r'[0-6]?[0-9]:[0-6]?[0-9]:[0-6 ]?[0-9]'

    date_regex1 = '/'.join([year_regex, month_regex, day_regex])
    date_regex2 = ':'.join([year_regex, month_regex, day_regex])
    date_regex3 = '-'.join([year_regex, month_regex, day_regex])
    datetime_regex1 = date_regex1 + ' ' + time_regex
    datetime_regex2 = date_regex2 + ' ' + time_regex
    datetime_regex3 = date_regex3 + 'T' + time_regex  # + r'\+[0-2]?[0-9]?[0-6]?[0-9]'
    datetime_regex4 = time_regex + ' ' + date_regex2 + ' 1'

    timefmt = None

    if re.match(datetime_regex1, clean_datetime_str):
        timefmt = '%Y/%m/%d %H:%M:%S'
    elif re.match(datetime_regex2, clean_datetime_str):
        timefmt = '%Y:%m:%d %H:%M:%S'
    elif re.match(datetime_regex3, clean_datetime_str):
        # timefmt = '%Y-%m-%dT%H:%M:%S%z'
        timefmt = '%Y-%m-%dT%H:%M:%S'
    elif re.match(datetime_regex4, clean_datetime_str):
        # timefmt = '%Y-%m-%dT%H:%M:%S%z'
        timefmt = '%H:%M:%S %Y:%m:%d 1'
    # Just dont accept this bad format
    #elif re.match(datetime_regex3, clean_datetime_str):
    #    timefmt = '%Y:%m:%d %H:%M: %S'
    else:
        if isinstance(clean_datetime_str, six.string_types):
            if len(clean_datetime_str.strip()) == 0:
                return None
            elif len(clean_datetime_str.strip(':/ ')) == 0:
                return None
            elif clean_datetime_str.find('No EXIF Data') == 0:
                return None
            elif clean_datetime_str.find('Invalid') == 0:
                return None
            elif clean_datetime_str == '0000:00:00 00:00:00':
                return None
            elif [ ord(_) >= 128 for _ in clean_datetime_str ].count(True) > 1:
                return None
        #return -1
        #import utool as ut
        #ut.embed()
        msg = 'Unknown format: datetime_str=%r' % (datetime_str,)
        print(msg)
        return None
        #raise NotImplementedError(msg)
    return timefmt