question on the 'calendar' function

o1bigtenor o1bigtenor at gmail.com
Tue Nov 20 13:07:10 EST 2018


On Tue, Nov 20, 2018 at 11:50 AM Schachner, Joseph
<Joseph.Schachner at teledyne.com> wrote:
>
> 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.
>

Greetings

If my syntax or commands are wrong - - - - I've just started so
something is likely to NOT be correct - - - grin - - - I'sa noob!

# calendar 2019

that is to show the year 2019

How could I show June 2018 to Dec 2019, inclusive?
Or June 2018 to Dec 2021, inclusive?
Or June 2018 to Dec 2023 by week (June wk 1,2,3,4 2018; July wk
1,2,3,4,5 2018; . . .   Dec wk 1,2,3,4,5 2023 or maybe even by dates),
inclusive?

Note that the time frame is ALWAYS more than 1 year.
AIUI there isn't a way to do that, at least not that I can see, and I
would like to be able to do that.
A friend suggested using a script wrapped around the command. I
thought maybe there might we a way of doing what I need to do without
using 2 levels of programming.

Regards



More information about the Python-list mailing list