from typing import Self

from attrs import define, field, validators


@define
class time:
    hours: int = field(validator=validators.in_(range(24)))
    minutes: int = field(validator=validators.in_(range(60)))
    seconds: int = field(validator=validators.in_(range(60)))

    def change(
        self: Self, hours: int | None, minutes: int | None, seconds: int | None
    ) -> Self:
        if hours is not None:
            self.hours += hours
        if minutes is not None:
            self.minutes += minutes
        if seconds is not None:
            self.seconds += seconds
        return self
