# Path: src/apscheduler/exceptions.py
# class DeserializationError(Exception):
#     """Raised when a serializer fails to deserialize the given object."""
# 
# class SerializationError(Exception):
#     """Raised when a serializer fails to serialize the given object."""


import sys
from datetime import date, datetime, tzinfo
from functools import partial
from typing import Any, Callable, overload
from .exceptions import DeserializationError, SerializationError
    from zoneinfo import ZoneInfo
    from backports.zoneinfo import ZoneInfo

def marshal_date(value):
    return value.isoformat() if value is not None else None


@overload
def unmarshal_date(value: None) -> None:
    ...


@overload
def unmarshal_date(value: str) -> date:
    ...


def unmarshal_date(value):
    if value is None:
        return None
    elif len(value) == 10:
        return date.fromisoformat(value)
    else:
        return datetime.fromisoformat(value)


def marshal_timezone(value: tzinfo) -> str:
    if isinstance(value, ZoneInfo):
        return value.key
    elif hasattr(value, 'zone'):  # pytz timezones
        return value.zone


# Path: src/apscheduler/exceptions.py
# class DeserializationError(Exception):
#     """Raised when a serializer fails to deserialize the given object."""
# 
# class SerializationError(Exception):
#     """Raised when a serializer fails to serialize the given object."""


# Path: src/apscheduler/marshalling.py
import sys
from datetime import date, datetime, tzinfo
from functools import partial
from typing import Any, Callable, overload
from .exceptions import DeserializationError, SerializationError
    from zoneinfo import ZoneInfo
    from backports.zoneinfo import ZoneInfo


def marshal_date(value):
    return value.isoformat() if value is not None else None


@overload
def unmarshal_date(value: None) -> None:
    ...


@overload
def unmarshal_date(value: str) -> date:
    ...


def unmarshal_date(value):
    if value is None:
        return None
    elif len(value) == 10:
        return date.fromisoformat(value)
    else:
        return datetime.fromisoformat(value)


def marshal_timezone(value: tzinfo) -> str:
    if isinstance(value, ZoneInfo):
        return value.key
    elif hasattr(value, 'zone'):  # pytz timezones
        return value.zone


    raise SerializationError(