Skip to content

Commit 7e63843

Browse files
committed
implement week support in start_of()/end_of() (#331)
1 parent 235e249 commit 7e63843

11 files changed

Lines changed: 770 additions & 231 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
This was achieved by deferring the import of several internal submodules
88
and timezone database setup until they are actually needed.
99
- Fixed CI compatibility with Python 3.13t (free-threaded build)
10+
- Added ``"week_mon"`` and ``"week_sun"`` as valid
11+
units for ``start_of()`` and ``end_of()`` on ``Date``, ``PlainDateTime``,
12+
``ZonedDateTime``, and ``OffsetDateTime``.
1013

1114
## 0.10.0 (2026-04-05)
1215

pysrc/whenever/__init__.pyi

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,26 @@ class Date(_DateOrTimeMixin):
175175
def prev_day(self) -> Date: ...
176176
def nth_weekday_of_month(self, n: int, weekday: Weekday, /) -> Date: ...
177177
def nth_weekday(self, n: int, weekday: Weekday, /) -> Date: ...
178-
def start_of(self, unit: Literal["year", "month"], /) -> Date: ...
179-
def end_of(self, unit: Literal["year", "month"], /) -> Date: ...
178+
def start_of(
179+
self,
180+
unit: Literal[
181+
"year",
182+
"month",
183+
"week_mon",
184+
"week_sun",
185+
],
186+
/,
187+
) -> Date: ...
188+
def end_of(
189+
self,
190+
unit: Literal[
191+
"year",
192+
"month",
193+
"week_mon",
194+
"week_sun",
195+
],
196+
/,
197+
) -> Date: ...
180198
def at(self, t: Time, /) -> PlainDateTime: ...
181199
def to_stdlib(self) -> _date: ...
182200
@deprecated("Use to_stdlib() instead")
@@ -1187,12 +1205,30 @@ class _LocalTime(ABC):
11871205
def in_leap_year(self) -> bool: ...
11881206
def start_of(
11891207
self,
1190-
unit: Literal["year", "month", "day", "hour", "minute", "second"],
1208+
unit: Literal[
1209+
"year",
1210+
"month",
1211+
"week_mon",
1212+
"week_sun",
1213+
"day",
1214+
"hour",
1215+
"minute",
1216+
"second",
1217+
],
11911218
/,
11921219
) -> Self: ...
11931220
def end_of(
11941221
self,
1195-
unit: Literal["year", "month", "day", "hour", "minute", "second"],
1222+
unit: Literal[
1223+
"year",
1224+
"month",
1225+
"week_mon",
1226+
"week_sun",
1227+
"day",
1228+
"hour",
1229+
"minute",
1230+
"second",
1231+
],
11961232
/,
11971233
) -> Self: ...
11981234
@overload
@@ -1617,14 +1653,32 @@ class OffsetDateTime(_PyDateTimeMixin, _ExactAndLocalTime):
16171653
) -> Self: ...
16181654
def start_of(
16191655
self,
1620-
unit: Literal["year", "month", "day", "hour", "minute", "second"],
1656+
unit: Literal[
1657+
"year",
1658+
"month",
1659+
"week_mon",
1660+
"week_sun",
1661+
"day",
1662+
"hour",
1663+
"minute",
1664+
"second",
1665+
],
16211666
/,
16221667
*,
16231668
stale_offset_ok: bool = ...,
16241669
) -> Self: ...
16251670
def end_of(
16261671
self,
1627-
unit: Literal["year", "month", "day", "hour", "minute", "second"],
1672+
unit: Literal[
1673+
"year",
1674+
"month",
1675+
"week_mon",
1676+
"week_sun",
1677+
"day",
1678+
"hour",
1679+
"minute",
1680+
"second",
1681+
],
16281682
/,
16291683
*,
16301684
stale_offset_ok: bool = ...,

0 commit comments

Comments
 (0)