Bases: BaseModel
Bespoke immutable date class designed to simplify working with dates,
in particular input parsing, date calculations, and ranges.
day
class-attribute
instance-attribute
day: int = Field(ge=1, le=31, frozen=True)
model_config
class-attribute
instance-attribute
model_config = ConfigDict(frozen=True)
month
class-attribute
instance-attribute
month: int = Field(ge=1, le=12, frozen=True)
prose
property
Prose English date string of the form Wednesday, March 17th 2025.
year
class-attribute
instance-attribute
year: int = Field(ge=1, le=1000000, frozen=True)
__add__
__add__(days: int) -> Date
Create a new date days later than self.
__and__
__and__(time: Time | DateTime) -> DateTime
__eq__
__eq__(other: object) -> bool
__ge__
__ge__(other: Any) -> bool
__gt__
__gt__(other: Any) -> bool
__le__
__le__(other: Any) -> bool
__lt__
__lt__(other: Any) -> bool
__pow__
__pow__(other: Date) -> DateRange
__sub__
__sub__(subtrahend: int) -> Date
__sub__(subtrahend: Date) -> int
__sub__(subtrahend: Date | int) -> Date | int
days_to
days_to(date2: Date) -> int
format(template: str) -> str
Returns a the date written out in long form.
from_ordinal
classmethod
from_ordinal(ord: int) -> Date
if_valid
classmethod
if_valid(date_string: str) -> Self | None
Parse a string and return an instance of Date if possible; otherwise None.
parse
classmethod
parse(date_string: str) -> Self
Alias for model_validate, but expects a string.
range
range(end: Date | int, inclusive: bool = False) -> list[Date]
Returns a list of consecutive days, default non-inclusive as is standard in Python.
Supports reverse-order ranges.
today
classmethod
Return todays date, using datetime.date.today() from the Python standard library.
validate_raw_date
classmethod
validate_raw_date(raw_date: str | dict | list | tuple) -> dict[str, str | int | float]