"""Temporal classes for years, months, days, hours, and weeks.

This module provides the core temporal domain classes used throughout the system.
"""

from dataclasses import dataclass


@dataclass
class Year:
    """Represents a year in the Gregorian calendar."""

    value: int

    def __str__(self) -> str:
        return str(self.value)

    def __repr__(self) -> str:
        return f"Year({self.value})"


@dataclass
class Month:
    """Represents a month (1-12)."""

    value: int

    def __post_init__(self) -> None:
        if not 1 <= self.value <= 12:
            raise ValueError(f"Month must be 1-12, got {self.value}")

    @property
    def name(self) -> str:
        """Get the month name."""
        names = [
            "January",
            "February",
            "March",
            "April",
            "May",
            "June",
            "July",
            "August",
            "September",
            "October",
            "November",
            "December",
        ]
        return names[self.value - 1]

    def __str__(self) -> str:
        return self.name

    def __repr__(self) -> str:
        return f"Month({self.value})"


@dataclass
class Week:
    """Represents a week in the calendar."""

    number: int  # 1-53
    year: int

    def __post_init__(self) -> None:
        if not 1 <= self.number <= 53:
            raise ValueError(f"Week must be 1-53, got {self.number}")

    def __str__(self) -> str:
        return f"Week {self.number} of {self.year}"

    def __repr__(self) -> str:
        return f"Week({self.number}, {self.year})"


@dataclass
class Day:
    """Represents a day of the month (1-31)."""

    value: int

    def __post_init__(self) -> None:
        if not 1 <= self.value <= 31:
            raise ValueError(f"Day must be 1-31, got {self.value}")

    @property
    def day_of_week(self) -> str:
        """Get day of week name - requires full date context."""
        pass

    def __str__(self) -> str:
        return str(self.value)

    def __repr__(self) -> str:
        return f"Day({self.value})"


@dataclass
class Hour:
    """Represents an hour in 24-hour format (0-23)."""

    value: int
    minute: int = 0
    second: int = 0

    def __post_init__(self) -> None:
        if not 0 <= self.value <= 23:
            raise ValueError(f"Hour must be 0-23, got {self.value}")
        if not 0 <= self.minute <= 59:
            raise ValueError(f"Minute must be 0-59, got {self.minute}")
        if not 0 <= self.second <= 59:
            raise ValueError(f"Second must be 0-59, got {self.second}")

    def __str__(self) -> str:
        return f"{self.value:02d}:{self.minute:02d}:{self.second:02d}"

    def __repr__(self) -> str:
        return f"Hour({self.value}, {self.minute}, {self.second})"
