Skip to content

Feature enhancement to calendar.monthcalendar #158541

Description

@andrecgurgel

Feature or enhancement

Problem: How to print a monthly calendar that shows - in different colot/format - the remaining days of the previous month (in the first week) and (in the last week) the first days of the next month.

Proposal: To add a property ("shoulderdays") or an optional argument to the function monthcalendar in the module calendar, so that, in the matrix returned, the days outside the requested month are negative integers, instead of zeros, so that these days can be so identified and properly displayed/printed in a different format or color.

The function returns the days of the month, sublisted by week, like this:

calendar.monthcalendar(2026, 10)
[[0, 0, 0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31, 0]]

Instead, the result could be:

calendar.monthcalendar(2026, 10, shoulderdays=true))
[[-28, -29, -30, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31, -1]]

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions