Skip to content

Commit

Permalink
Issue fitnr#58: monthcalendar makes 6-day week.
Browse files Browse the repository at this point in the history
We don't really have to compute the ending day or the rpad anyway.
  • Loading branch information
Mark E. Shoulson committed May 22, 2023
1 parent 5c955e8 commit 1b0d652
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/convertdate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ def n_weeks(weekday, jd, nthweek):


def monthcalendarhelper(start_weekday, month_length):
end_weekday = start_weekday + (month_length - 1) % 7

lpad = (start_weekday + 1) % 7
rpad = (5 - end_weekday % 7) % 6

days = [None] * lpad + list(range(1, 1 + month_length)) + rpad * [None]
days = [None] * lpad + list(range(1, 1 + month_length)) + 7 * [None]

return [days[i : i + 7] for i in range(0, len(days), 7)]
return [days[i : i + 7] for i in range(0, lpad + month_length, 7)]


def nth_day_of_month(n, weekday, month, year):
Expand Down

0 comments on commit 1b0d652

Please sign in to comment.