Hi, the documentation mentions to use Date.nth_weekday(...) as a replacement for Date.start_of("week") but this does not really solve the problem nicely.
Assume that weeks start on Monday, and we have a d = Date(2026, 4, 20) (a Monday). Then there is no way in which I can call (d.nth_weekday(...), which would return d itself (I will either get the next Monday, or the previous one). Compare to Date(2026, 4, 1).start_of("month") == Date(2026, 4, 1).
This is mainly a request for consideration of an improvement of the api, as the problem can be worked around simply by d.subtract(days=d.day_of_week().value - 1).
My naive idea would be a method similar to the nth_weekday(n, weekday), that for n > 0 would work as it does now, but would allow n = 0 as a viable input, and would satisfy d.nth_weekday(n, weekday).subtract(weeks=m) == d.nth_weekday(n - m, weekday).
Hi, the documentation mentions to use
Date.nth_weekday(...)as a replacement forDate.start_of("week")but this does not really solve the problem nicely.Assume that weeks start on Monday, and we have a
d = Date(2026, 4, 20)(a Monday). Then there is no way in which I can call(d.nth_weekday(...), which would returnditself (I will either get the next Monday, or the previous one). Compare toDate(2026, 4, 1).start_of("month") == Date(2026, 4, 1).This is mainly a request for consideration of an improvement of the api, as the problem can be worked around simply by
d.subtract(days=d.day_of_week().value - 1).My naive idea would be a method similar to the
nth_weekday(n, weekday), that forn > 0would work as it does now, but would allown = 0as a viable input, and would satisfyd.nth_weekday(n, weekday).subtract(weeks=m) == d.nth_weekday(n - m, weekday).