(data, schema)
Converts datetime.datetime to int timestamp with microseconds
Converts datetime.datetime to int timestamp with microseconds
Converts datetime . datetime to int timestamp with microseconds
def prepare_timestamp_micros(data, schema):
    """Converts datetime.datetime to int timestamp with microseconds"""
    if isinstance(data, datetime.datetime):
        if data.tzinfo is not None:
            delta = data - epoch
            return (
                delta.days * 24 * 3600 + delta.seconds
            ) * MCS_PER_SECOND + delta.microseconds

        # On Windows, mktime does not support pre-epoch, see e.g.
        # https://stackoverflow.com/questions/2518706/python-mktime-overflow-error
        if is_windows:
            delta = data - epoch_naive
            return (
                delta.days * 24 * 3600 + delta.seconds
            ) * MCS_PER_SECOND + delta.microseconds
        else:
            return (
                int(time.mktime(data.timetuple())) * MCS_PER_SECOND + data.microsecond
            )
    else:
        return data
def prepare_timestamp_micros ( data , schema ) : if isinstance ( data , datetime . datetime ) : if data . tzinfo is not None : delta = data - epoch return ( delta . days * 24 * 3600 + delta . seconds ) * MCS_PER_SECOND + delta . microseconds # On Windows, mktime does not support pre-epoch, see e.g. # https://stackoverflow.com/questions/2518706/python-mktime-overflow-error if is_windows : delta = data - epoch_naive return ( delta . days * 24 * 3600 + delta . seconds ) * MCS_PER_SECOND + delta . microseconds else : return ( int ( time . mktime ( data . timetuple ( ) ) ) * MCS_PER_SECOND + data . microsecond ) else : return data