Skip to content

Date

datethyme.Date

Bases: OptionalDate, BaseModel

Methods:

Attributes:

datetime: DateTime property

model_config = ConfigDict(frozen=True) class-attribute instance-attribute

year: int = Field(ge=1, le=1000000, frozen=True) class-attribute instance-attribute

month: int = Field(ge=1, le=12, frozen=True) class-attribute instance-attribute

day: int = Field(ge=1, le=31, frozen=True) class-attribute instance-attribute

stdlib: DATETIME.date property

ordinal: int property

weekday_ordinal: int property

weekday: WeekdayLiteral property

prose: str property

Prose English date string of the form Wednesday, March 17th 2025.

start: DateTime property

end: DateTime property

span: DateTimeSpan property

__and__(time: OptionalTime) -> DateTime

__pow__(other: Date) -> DateRange

validate_date(raw_date: str | dict | list | tuple) -> dict[str, str | int | float] classmethod

serialize_date() -> str

__str__() -> str

__repr__() -> str

__bool__() -> bool

__add__(days: int) -> Date

Create a new date days later than self.

__sub__(subtrahend: Date) -> int

__eq__(other: object) -> bool

__lt__(other: Any) -> bool

__gt__(other: Any) -> bool

__le__(other: Any) -> bool

__ge__(other: Any) -> bool

__int__() -> int

__hash__() -> int

parse(date_string: str) -> Self classmethod

Alias for model_validate, but expects a string.

if_valid(date_string: str) -> Self | NoneDate classmethod

Parse a string and return an instance of Date if possible; otherwise None.

today() -> Date classmethod

Return todays date, using datetime.date.today() from the Python standard library.

from_ordinal(ord: int) -> Date classmethod

tomorrow() -> Date classmethod

none() -> NoneDate staticmethod

days_to(date2: Date) -> int

format(template: str) -> str

Returns a the date written out in long form.

range(end: Union[Date, int], inclusive: bool = True) -> list[Date]

Returns a list of consecutive days, default inclusive. Supports reverse-order ranges.