r"""
    converts a datetime string to posixtime (unixtime)
    Use parse timestamp instead

    Args:
        datetime_str     (str):
        timestamp_format (int):

    Returns:
        int: unixtime seconds from 1970 (currently not UTC; this will change)

    CommandLine:
        python -m utool.util_time --test-exiftime_to_unixtime:2

    Example0:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '0000:00:00 00:00:00'
        >>> timestamp_format = 1
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        -1

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '2015:04:01 00:00:00'
        >>> timestamp_format = 1
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        1427846400

    Example2:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '2005-10-27T14:35:20+02:00'
        >>> timestamp_format = None
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        1130423720

    Example3:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '6:35:01\x002006:03:19 1'
        >>> timestamp_format = None
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        1142750101

def exiftime_to_unixtime(datetime_str, timestamp_format=None, strict=None):
    r"""
    converts a datetime string to posixtime (unixtime)
    Use parse timestamp instead

    Args:
        datetime_str     (str):
        timestamp_format (int):

    Returns:
        int: unixtime seconds from 1970 (currently not UTC; this will change)

    CommandLine:
        python -m utool.util_time --test-exiftime_to_unixtime:2

    Example0:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '0000:00:00 00:00:00'
        >>> timestamp_format = 1
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        -1

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '2015:04:01 00:00:00'
        >>> timestamp_format = 1
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        1427846400

    Example2:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '2005-10-27T14:35:20+02:00'
        >>> timestamp_format = None
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        1130423720

    Example3:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_time import *  # NOQA
        >>> datetime_str = '6:35:01\x002006:03:19 1'
        >>> timestamp_format = None
        >>> result = exiftime_to_unixtime(datetime_str, timestamp_format)
        >>> print(result)
        1142750101
    """
    invalid_value = -1
    if isinstance(datetime_str, int):
        if datetime_str == -1:
            return invalid_value
    elif datetime_str is None:
        return None

    # TODO: use parse_timestamp to reduce duplicate code
    #try:
    #    dt = parse_timestamp(datetime_str)
    #except TypeError:
    #    #if datetime_str is None:
    #        #return -1
    #    return -1
    #except ValueError as ex:
    #    if strict is None:
    #        ...

    if not isinstance(datetime_str, six.string_types):
        raise NotImplementedError('Unknown format: datetime_str=%r' % (datetime_str,))
    # Normal format, or non-standard year first data
    if timestamp_format is None:
        timefmt = determine_timestamp_format(datetime_str)
        if timefmt is None:
            return invalid_value
    elif timestamp_format == 2:
        timefmt = '%m/%d/%Y %H:%M:%S'
    elif timestamp_format == 1:
        timefmt = '%Y:%m:%d %H:%M:%S'
    else:
        assert isinstance(timestamp_format, six.string_types)
        timefmt = timestamp_format
        #raise AssertionError('unknown timestamp_format=%r' % (timestamp_format,))
    try:
        if len(datetime_str) == 20 and '\x00' in datetime_str:
            datetime_str_ = datetime_str.replace('\x00', ' ').strip(';').strip()
        elif len(datetime_str) > 19:
            datetime_str_ = datetime_str[:19].strip(';').strip()
        else:
            datetime_str_ = datetime_str
        #try:
        dt = datetime.datetime.strptime(datetime_str_, timefmt)
        #except ValueError as ex:
        #    import utool as ut
        #    ut.printex(ex, iswarning=True)
        #    return invalid_value
        return calendar.timegm(dt.timetuple())
        #return time.mktime(dt.timetuple())
    except TypeError:
        #if datetime_str is None:
            #return -1
        return -1
    except ValueError as ex:
        if strict is None:
            strict = util_arg.SUPER_STRICT
        #strict = False
        #from utool.util_arg import STRICT
        if isinstance(datetime_str, six.string_types):
            if len(datetime_str_.strip()) == 0:
                return invalid_value
            if datetime_str_.find('No EXIF Data') == 0:
                return invalid_value
            if datetime_str_.find('Invalid') == 0:
                return invalid_value
            if datetime_str_ == '0000:00:00 00:00:00':
                return invalid_value
        print('<!!! ValueError !!!>')
        print('[util_time] Caught Error: ' + repr(ex))
        print('[util_time] type(datetime_str)  = %r' % type(datetime_str))
        print('[util_time] repr(datetime_str)  = %r' % datetime_str)
        print('[util_time]     (datetime_str)  = %s' % datetime_str)
        print('[util_time]  len(datetime_str)  = %d' % len(datetime_str))
        print('[util_time] repr(datetime_str_) = %r' % datetime_str_)
        print('[util_time]  len(datetime_str_) = %d' % len(datetime_str_))
        print('</!!! ValueError !!!>')

        debug = True
        if debug:
            def find_offending_part(datetime_str_, timefmt, splitchar=' '):
                import utool as ut
                parts_list = datetime_str_.split(splitchar)
                fmt_list = timefmt.split(splitchar)
                if len(parts_list) == 1:
                    return
                for part, fmt in zip(parts_list, fmt_list):
                    print('Trying:')
                    with ut.Indenter('  '):
                        try:
                            print('fmt = %r' % (fmt,))
                            print('part = %r' % (part,))
                            datetime.datetime.strptime(part, fmt)
                        except ValueError:
                            find_offending_part(part, fmt, '/')
                            print('Failed')
                        else:
                            print('Passed')
            find_offending_part(datetime_str_, timefmt)

        #import utool as ut
        #ut.embed()
        if strict:
            raise
        else:
            print('Supressed ValueError')
            return invalid_value