# Path: fastavro/__main__.py
# class CleanJSONEncoder(json.JSONEncoder):
#     def default(self, obj):
#         if isinstance(obj, (datetime.date, datetime.datetime)):
#             return obj.isoformat()
#         elif isinstance(obj, (Decimal, UUID)):
#             return str(obj)
#         elif isinstance(obj, bytes):
#             return obj.decode("iso-8859-1")
#         else:
#             return json.JSONEncoder.default(self, obj)
# 
# Path: tests/conftest.py
# def assert_naive_datetime_equal_to_tz_datetime(naive_datetime, tz_datetime):
#     # mktime appears to ignore microseconds, so do this manually
#     microseconds = int(time.mktime(naive_datetime.timetuple())) * 1000 * 1000
#     microseconds += naive_datetime.microsecond
#     aware_datetime = datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(
#         microseconds=microseconds
#     )
#     assert aware_datetime == tz_datetime


import fastavro
import json
import pytest
import datetime
import sys
import os
import numpy as np
    import pandas as pd
from fastavro.__main__ import CleanJSONEncoder
from decimal import Decimal
from io import BytesIO
from uuid import uuid4
from datetime import timezone, timedelta
from .conftest import assert_naive_datetime_equal_to_tz_datetime
    assert data2["date"] == datetime.date(2017, 1, 1)


def test_ancient_datetime():
    schema_datetime = {
        "fields": [
            {
                "name": "timestamp-millis",
                "type": {"type": "long", "logicalType": "timestamp-millis"},
            },
            {
                "name": "timestamp-micros",
                "type": {"type": "long", "logicalType": "timestamp-micros"},
            },
        ],
        "namespace": "namespace",
        "name": "name",
        "type": "record",
    }

    data1 = {
        "timestamp-millis": datetime.datetime(1960, 1, 1),
        "timestamp-micros": datetime.datetime(1960, 1, 1),
    }
    binary = serialize(schema_datetime, data1)
    data2 = deserialize(schema_datetime, binary)

    assert_naive_datetime_equal_to_tz_datetime(
        data1["timestamp-millis"], data2["timestamp-millis"]
    )

# Path: fastavro/__main__.py
# class CleanJSONEncoder(json.JSONEncoder):
#     def default(self, obj):
#         if isinstance(obj, (datetime.date, datetime.datetime)):
#             return obj.isoformat()
#         elif isinstance(obj, (Decimal, UUID)):
#             return str(obj)
#         elif isinstance(obj, bytes):
#             return obj.decode("iso-8859-1")
#         else:
#             return json.JSONEncoder.default(self, obj)
# 
# Path: tests/conftest.py
# def assert_naive_datetime_equal_to_tz_datetime(naive_datetime, tz_datetime):
#     # mktime appears to ignore microseconds, so do this manually
#     microseconds = int(time.mktime(naive_datetime.timetuple())) * 1000 * 1000
#     microseconds += naive_datetime.microsecond
#     aware_datetime = datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(
#         microseconds=microseconds
#     )
#     assert aware_datetime == tz_datetime


# Path: tests/test_logical_types.py
import fastavro
import json
import pytest
import datetime
import sys
import os
import numpy as np
    import pandas as pd
from fastavro.__main__ import CleanJSONEncoder
from decimal import Decimal
from io import BytesIO
from uuid import uuid4
from datetime import timezone, timedelta
from .conftest import assert_naive_datetime_equal_to_tz_datetime

    assert data2["date"] == datetime.date(2017, 1, 1)


def test_ancient_datetime():
    schema_datetime = {
        "fields": [
            {
                "name": "timestamp-millis",
                "type": {"type": "long", "logicalType": "timestamp-millis"},
            },
            {
                "name": "timestamp-micros",
                "type": {"type": "long", "logicalType": "timestamp-micros"},
            },
        ],
        "namespace": "namespace",
        "name": "name",
        "type": "record",
    }

    data1 = {
        "timestamp-millis": datetime.datetime(1960, 1, 1),
        "timestamp-micros": datetime.datetime(1960, 1, 1),
    }
    binary = serialize(schema_datetime, data1)
    data2 = deserialize(schema_datetime, binary)

    assert_naive_datetime_equal_to_tz_datetime(
        data1["timestamp-millis"], data2["timestamp-millis"]
    )

    assert_naive_datetime_equal_to_tz_datetime(