|  |  |  | 
|---|
|  |  |  | y0 = year - ((14 - month) // 12) | 
|---|
|  |  |  | x = y0 + (y0 // 4) - (y0 // 100) + (y0 // 400) | 
|---|
|  |  |  | m0 = month + 12 * ((14 - month) // 12) - 2 | 
|---|
|  |  |  | return (day + x +(31 * m0) // 12) % 7 | 
|---|
|  |  |  | return (day + x + (31 * m0) // 12) % 7 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def count_days_in_month(month: int, year: int) -> int: | 
|---|
|  |  |  | count_days = months[month][1] | 
|---|
|  |  |  | if month == 2 and is_leap_year(year): count_days += 1 | 
|---|
|  |  |  | if month == 2 and is_leap_year(year): | 
|---|
|  |  |  | count_days += 1 | 
|---|
|  |  |  | return count_days | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | days_in_month = count_days_in_month(month, year) | 
|---|
|  |  |  | while day <= days_in_month: | 
|---|
|  |  |  | month_view += format_day(day, column_width) | 
|---|
|  |  |  | if (day + diff) % 7 == 0: month_view += "\n" | 
|---|
|  |  |  | if (day + diff) % 7 == 0 and (day < days_in_month): | 
|---|
|  |  |  | month_view += "\n" | 
|---|
|  |  |  | day += 1 | 
|---|
|  |  |  | return month_view | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | weekdays_line = build_weekdays_line(column_width) | 
|---|
|  |  |  | calendar_view += f"{weekdays_line}\n" | 
|---|
|  |  |  | month_view = build_month_view(month, year, column_width) | 
|---|
|  |  |  | calendar_view += f"{month_view}\n" | 
|---|
|  |  |  | calendar_view += f"{month_view}" | 
|---|
|  |  |  | return calendar_view | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|