question on the 'calendar' function

Schachner, Joseph Joseph.Schachner at Teledyne.com
Tue Nov 20 12:50:45 EST 2018


It's possible I don't understand the question.  The calendar functions are NOT limited to this year or any limited range.

Example:
import calendar
print( calendar.monthcalendar(2022, 12) )

Prints lists of dates in each week of December 2022.  It prints:
[[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]]

So, Dec 1 is a Wednesday; Dec 31 is a Saturday.  

That's 49 months ahead of this month.   Change the year and month to any (valid) number, and it will do what it does.  
The only caveat is that if the moon's orbit slows down as it gets farther away from the earth and the earth's rotation speed changes, then the calculations done by calendar for leap years may not be correct about the distant future.

--- Joseph S.


-----Original Message-----
From: o1bigtenor <o1bigtenor at gmail.com> 
Sent: Tuesday, November 20, 2018 8:37 AM
To: python-list at python.org
Subject: question on the 'calendar' function

Greetings

I am in the process of learning my first computer programming language (unless g-code counts and then it is my second - - - grin). It definitely is a big world out there.

The calendar function has a lot of versatility and shows care in its development.

There is one area where I don't understand if I even could use this function or if I need to look to something(s) else to achieve what I need.

For planning I need to be able to easily look backward 6 months and forward at least 12 and better 18 months and would prefer perhaps even a total of 36 (and even 60 might be useful) months of calendar available. It could be useful to see the longer time spans as weeks rather than as days but seeing the larger time frames only as months would enable the planning that I need to do.

Do I need to (somehow and I have no idea how) extend the calendar function?
Is there some other way of displaying dates/calendars that would allow me to achieve my needed span?

TIA



More information about the Python-list mailing list