# Path: fastavro/const.py
# MCS_PER_HOUR = MCS_PER_MINUTE * 60
# 
# MCS_PER_MINUTE = MCS_PER_SECOND * 60
# 
# MCS_PER_SECOND = 1000000
# 
# MLS_PER_HOUR = MLS_PER_MINUTE * 60
# 
# MLS_PER_MINUTE = MLS_PER_SECOND * 60
# 
# MLS_PER_SECOND = 1000
# 
# DAYS_SHIFT = datetime.date(1970, 1, 1).toordinal()


import datetime
import decimal
import os
import time
import uuid
from io import BytesIO
from typing import Dict, Union
from .const import (
    MCS_PER_HOUR,
    MCS_PER_MINUTE,
    MCS_PER_SECOND,
    MLS_PER_HOUR,
    MLS_PER_MINUTE,
    MLS_PER_SECOND,
    DAYS_SHIFT,
)

def prepare_uuid(data, schema):
    """Converts uuid.UUID to
    string formatted UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    """
    if isinstance(data, uuid.UUID):
        return str(data)
    else:
        return data


def prepare_time_millis(data, schema):
    """Convert datetime.time to int timestamp with milliseconds"""
    if isinstance(data, datetime.time):
        return int(
            data.hour * MLS_PER_HOUR
            + data.minute * MLS_PER_MINUTE
            + data.second * MLS_PER_SECOND
            + int(data.microsecond / 1000)
        )
    else:
        return data


def prepare_time_micros(data, schema):
    """Convert datetime.time to int timestamp with microseconds"""
    if isinstance(data, datetime.time):
        return int(
            data.hour * MCS_PER_HOUR
            + data.minute * MCS_PER_MINUTE

# Path: fastavro/const.py
# MCS_PER_HOUR = MCS_PER_MINUTE * 60
# 
# MCS_PER_MINUTE = MCS_PER_SECOND * 60
# 
# MCS_PER_SECOND = 1000000
# 
# MLS_PER_HOUR = MLS_PER_MINUTE * 60
# 
# MLS_PER_MINUTE = MLS_PER_SECOND * 60
# 
# MLS_PER_SECOND = 1000
# 
# DAYS_SHIFT = datetime.date(1970, 1, 1).toordinal()


# Path: fastavro/_logical_writers_py.py
import datetime
import decimal
import os
import time
import uuid
from io import BytesIO
from typing import Dict, Union
from .const import (
    MCS_PER_HOUR,
    MCS_PER_MINUTE,
    MCS_PER_SECOND,
    MLS_PER_HOUR,
    MLS_PER_MINUTE,
    MLS_PER_SECOND,
    DAYS_SHIFT,
)


def prepare_uuid(data, schema):
    """Converts uuid.UUID to
    string formatted UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    """
    if isinstance(data, uuid.UUID):
        return str(data)
    else:
        return data


def prepare_time_millis(data, schema):
    """Convert datetime.time to int timestamp with milliseconds"""
    if isinstance(data, datetime.time):
        return int(
            data.hour * MLS_PER_HOUR
            + data.minute * MLS_PER_MINUTE
            + data.second * MLS_PER_SECOND
            + int(data.microsecond / 1000)
        )
    else:
        return data


def prepare_time_micros(data, schema):
    """Convert datetime.time to int timestamp with microseconds"""
    if isinstance(data, datetime.time):
        return int(
            data.hour * MCS_PER_HOUR
            + data.minute * MCS_PER_MINUTE

            + data.second * MCS_PER_SECOND