IsoWeekDate

class whenever.IsoWeekDate(iso_string: str, /)[source]
class whenever.IsoWeekDate(year: int, week: int, weekday: Weekday, /)

An ISO 8601 week date—a year, week number, and weekday.

The ISO week year may differ from the Gregorian year at year boundaries.

>>> iwd = IsoWeekDate(2024, 1, Weekday.MONDAY)
IsoWeekDate("2024-W01-1")

Can also be constructed from an ISO 8601 string:

>>> IsoWeekDate("2024-W01-1")
IsoWeekDate("2024-W01-1")
classmethod parse_iso(s: str, /) IsoWeekDate[source]

Parse an ISO 8601 week date string

>>> IsoWeekDate.parse_iso("2024-W01-1")
IsoWeekDate("2024-W01-1")
__eq__(other: object) bool[source]

Compare for equality

>>> IsoWeekDate(2024, 1, Weekday.MONDAY) == IsoWeekDate(2024, 1, Weekday.MONDAY)
True
__ge__(other: IsoWeekDate) bool[source]

Return self>=value.

__gt__(other: IsoWeekDate) bool[source]

Return self>value.

__le__(other: IsoWeekDate) bool[source]

Return self<=value.

__lt__(other: IsoWeekDate) bool[source]

Return self<value.

__str__() str[source]

Return str(self).

date() Date[source]

Convert to the corresponding Gregorian Date

>>> IsoWeekDate(2025, 1, Weekday.MONDAY).date()
Date("2024-12-30")
format_iso(*, basic: bool = False) str[source]

Format as an ISO 8601 week date string

>>> IsoWeekDate(2024, 1, Weekday.MONDAY).format_iso()
'2024-W01-1'
>>> IsoWeekDate(2024, 1, Weekday.MONDAY).format_iso(basic=True)
'2024W011'
replace(*, year: int = ..., week: int = ..., weekday: Weekday = ...) IsoWeekDate[source]

Return a new IsoWeekDate with the given fields replaced

>>> IsoWeekDate(2024, 1, Weekday.MONDAY).replace(week=10)
IsoWeekDate("2024-W10-1")
weeks_in_year() int[source]

Number of weeks in this ISO week year (52 or 53)

>>> IsoWeekDate(2004, 53, Weekday.FRIDAY).weeks_in_year()
53
>>> IsoWeekDate(2024, 1, Weekday.MONDAY).weeks_in_year()
52
MAX: ClassVar[IsoWeekDate] = IsoWeekDate("9999-W52-5")

The maximum possible ISO week date

MIN: ClassVar[IsoWeekDate] = IsoWeekDate("0001-W01-1")

The minimum possible ISO week date

property week: int

The ISO week number (1–53)

>>> IsoWeekDate(2024, 1, Weekday.MONDAY).week
1
property weekday: Weekday

The day of the week

>>> IsoWeekDate(2024, 1, Weekday.MONDAY).weekday
Weekday.MONDAY
property year: int

The ISO week year

>>> IsoWeekDate(2024, 1, Weekday.MONDAY).year
2024