Date
datethyme.Date
Bases: OptionalDate
, BaseModel
Methods:
-
__and__
– -
__pow__
– -
validate_date
– -
serialize_date
– -
__str__
– -
__repr__
– -
__bool__
– -
__add__
–Create a new date
days
later thanself
. -
__sub__
– -
__eq__
– -
__lt__
– -
__gt__
– -
__le__
– -
__ge__
– -
__int__
– -
__hash__
– -
parse
–Alias for
model_validate
, but expects a string. -
if_valid
–Parse a string and return an instance of Date if possible; otherwise None.
-
today
–Return todays date, using datetime.date.today() from the Python standard library.
-
from_ordinal
– -
tomorrow
– -
none
– -
days_to
– -
format
–Returns a the date written out in long form.
-
range
–Returns a list of consecutive days, default inclusive. Supports reverse-order ranges.
Attributes:
-
datetime
(DateTime
) – -
model_config
– -
year
(int
) – -
month
(int
) – -
day
(int
) – -
stdlib
(date
) – -
ordinal
(int
) – -
weekday_ordinal
(int
) – -
weekday
(WeekdayLiteral
) – -
prose
(str
) –Prose English date string of the form
Wednesday, March 17th 2025
. -
start
(DateTime
) – -
end
(DateTime
) – -
span
(DateTimeSpan
) –
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.