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_hours
classmethod
from_hours(n: float | int) -> Self
from_minutes
classmethod
from_minutes(n: float | int) -> Self
from_ordinal
classmethod
from_ordinal(ord: int) -> Self
from_seconds
classmethod
from_seconds(n: float | int, places: int | None = 10) -> Self
if_valid
classmethod
if_valid(raw_date: object) -> Self | None
Parse a string and return an instance of Date if possible; otherwise None.
parse
classmethod
Alias for model_validate, but expects a string.
range
range(stop: Date | int, step: int = 1, inclusive: bool = False) -> DateRange
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, int | float]
ymd
classmethod
ymd(year: int, month: int, day: int) -> Self