# Path: src/apscheduler/abc.py
# class Trigger(Iterator[datetime], metaclass=ABCMeta):
#     """Abstract base class that defines the interface that every trigger must implement."""
# 
#     __slots__ = ()
# 
#     @abstractmethod
#     def next(self) -> datetime | None:
#         """
#         Return the next datetime to fire on.
# 
#         If no such datetime can be calculated, ``None`` is returned.
#         :raises apscheduler.exceptions.MaxIterationsReached:
#         """
# 
#     @abstractmethod
#     def __getstate__(self):
#         """Return the (JSON compatible) serializable state of the trigger."""
# 
#     @abstractmethod
#     def __setstate__(self, state):
#         """Initialize an empty instance from an existing state."""
# 
#     def __iter__(self):
#         return self
# 
#     def __next__(self) -> datetime:
#         dateval = self.next()
#         if dateval is None:
#             raise StopIteration
#         else:
#             return dateval
# 
# Path: src/apscheduler/marshalling.py
# @overload
# def marshal_date(value: None) -> None:
#     ...
# 
# @overload
# def unmarshal_date(value: None) -> None:
#     ...
# 
# Path: src/apscheduler/validators.py
# def as_aware_datetime(value: datetime | str | None) -> datetime | None:
#     """
#     Convert the value to a timezone aware datetime.
# 
#     :param value: a datetime, an ISO 8601 representation of a datetime, or ``None``
#     :param tz: timezone to use for making the datetime timezone aware
#     :return: a timezone aware datetime, or ``None`` if ``None`` was given
# 
#     """
#     if value is None:
#         return None
# 
#     if isinstance(value, str):
#         if value.upper().endswith('Z'):
#             value = value[:-1] + '+00:00'
# 
#         value = datetime.fromisoformat(value)
# 
#     if isinstance(value, datetime):
#         if not value.tzinfo:
#             return value.replace(tzinfo=get_localzone())
#         else:
#             return value
# 
#     raise TypeError(f'Expected string or datetime, got {value.__class__.__qualname__} instead')
# 
# def require_state_version(trigger: Trigger, state: dict[str, Any], max_version: int) -> None:
#     try:
#         if state['version'] > max_version:
#             raise DeserializationError(
#                 f'{trigger.__class__.__name__} received a serialized state with version '
#                 f'{state["version"]}, but it only supports up to version {max_version}. '
#                 f'This can happen when an older version of APScheduler is being used with a data '
#                 f'store that was previously used with a newer APScheduler version.'
#             )
#     except KeyError as exc:
#         raise DeserializationError('Missing "version" key in the serialized state') from exc


from datetime import datetime
from typing import Any
from ..abc import Trigger
from ..marshalling import marshal_date, unmarshal_date
from ..validators import as_aware_datetime, require_state_version
import attrs
from __future__ import annotations





@attrs.define
class DateTrigger(Trigger):
    """
    Triggers once on the given date/time.

    :param run_time: the date/time to run the job at
    """

    run_time: datetime = attrs.field(converter=as_aware_datetime)
    _completed: bool = attrs.field(init=False, eq=False, default=False)

    def next(self) -> datetime | None:
        if not self._completed:
            self._completed = True
            return self.run_time
        else:
            return None

    def __getstate__(self) -> dict[str, Any]:
        return {
            'version': 1,

# Path: src/apscheduler/abc.py
# class Trigger(Iterator[datetime], metaclass=ABCMeta):
#     """Abstract base class that defines the interface that every trigger must implement."""
# 
#     __slots__ = ()
# 
#     @abstractmethod
#     def next(self) -> datetime | None:
#         """
#         Return the next datetime to fire on.
# 
#         If no such datetime can be calculated, ``None`` is returned.
#         :raises apscheduler.exceptions.MaxIterationsReached:
#         """
# 
#     @abstractmethod
#     def __getstate__(self):
#         """Return the (JSON compatible) serializable state of the trigger."""
# 
#     @abstractmethod
#     def __setstate__(self, state):
#         """Initialize an empty instance from an existing state."""
# 
#     def __iter__(self):
#         return self
# 
#     def __next__(self) -> datetime:
#         dateval = self.next()
#         if dateval is None:
#             raise StopIteration
#         else:
#             return dateval
# 
# Path: src/apscheduler/marshalling.py
# @overload
# def marshal_date(value: None) -> None:
#     ...
# 
# @overload
# def unmarshal_date(value: None) -> None:
#     ...
# 
# Path: src/apscheduler/validators.py
# def as_aware_datetime(value: datetime | str | None) -> datetime | None:
#     """
#     Convert the value to a timezone aware datetime.
# 
#     :param value: a datetime, an ISO 8601 representation of a datetime, or ``None``
#     :param tz: timezone to use for making the datetime timezone aware
#     :return: a timezone aware datetime, or ``None`` if ``None`` was given
# 
#     """
#     if value is None:
#         return None
# 
#     if isinstance(value, str):
#         if value.upper().endswith('Z'):
#             value = value[:-1] + '+00:00'
# 
#         value = datetime.fromisoformat(value)
# 
#     if isinstance(value, datetime):
#         if not value.tzinfo:
#             return value.replace(tzinfo=get_localzone())
#         else:
#             return value
# 
#     raise TypeError(f'Expected string or datetime, got {value.__class__.__qualname__} instead')
# 
# def require_state_version(trigger: Trigger, state: dict[str, Any], max_version: int) -> None:
#     try:
#         if state['version'] > max_version:
#             raise DeserializationError(
#                 f'{trigger.__class__.__name__} received a serialized state with version '
#                 f'{state["version"]}, but it only supports up to version {max_version}. '
#                 f'This can happen when an older version of APScheduler is being used with a data '
#                 f'store that was previously used with a newer APScheduler version.'
#             )
#     except KeyError as exc:
#         raise DeserializationError('Missing "version" key in the serialized state') from exc


# Path: src/apscheduler/triggers/date.py
from datetime import datetime
from typing import Any
from ..abc import Trigger
from ..marshalling import marshal_date, unmarshal_date
from ..validators import as_aware_datetime, require_state_version
import attrs

from __future__ import annotations





@attrs.define
class DateTrigger(Trigger):
    """
    Triggers once on the given date/time.

    :param run_time: the date/time to run the job at
    """

    run_time: datetime = attrs.field(converter=as_aware_datetime)
    _completed: bool = attrs.field(init=False, eq=False, default=False)

    def next(self) -> datetime | None:
        if not self._completed:
            self._completed = True
            return self.run_time
        else:
            return None

    def __getstate__(self) -> dict[str, Any]:
        return {
            'version': 1,

            'run_time': marshal_date(self.run_time),