On Tuesday, November 20, 2018 at 7:53:06 PM UTC+1, o1bigtenor wrote:
> On Tue, Nov 20, 2018 at 11:50 AM Schachner, Joseph
> <joseph.schach...@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

>From what you post it seems like you are on a Linux kind of system and you are 
>running the `calendar` command in the bash terminal. If that is correct, try 
>the following:

In the bash terminal type (without the literal #):
# python 

This will put you in the Python prompt (marked with >>>).
Check that the first line starts with Python 3. If not, I highly recommend
you install Python 3. If it is Python two, the following will work, but you
have to drop the outer parentheses for print (thus print calendar.calendar()) 

Then type the following:
>>> import calendar
>>> print(calendar.calendar(2020))

This will show:
                                  2020

      January                   February                   March
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
       1  2  3  4  5                      1  2                         1
 6  7  8  9 10 11 12       3  4  5  6  7  8  9       2  3  4  5  6  7  8
13 14 15 16 17 18 19      10 11 12 13 14 15 16       9 10 11 12 13 14 15
20 21 22 23 24 25 26      17 18 19 20 21 22 23      16 17 18 19 20 21 22
27 28 29 30 31            24 25 26 27 28 29         23 24 25 26 27 28 29
                                                    30 31

       April                      May                       June
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
       1  2  3  4  5                   1  2  3       1  2  3  4  5  6  7
 6  7  8  9 10 11 12       4  5  6  7  8  9 10       8  9 10 11 12 13 14
13 14 15 16 17 18 19      11 12 13 14 15 16 17      15 16 17 18 19 20 21
20 21 22 23 24 25 26      18 19 20 21 22 23 24      22 23 24 25 26 27 28
27 28 29 30               25 26 27 28 29 30 31      29 30

        July                     August                  September
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
       1  2  3  4  5                      1  2          1  2  3  4  5  6
 6  7  8  9 10 11 12       3  4  5  6  7  8  9       7  8  9 10 11 12 13
13 14 15 16 17 18 19      10 11 12 13 14 15 16      14 15 16 17 18 19 20
20 21 22 23 24 25 26      17 18 19 20 21 22 23      21 22 23 24 25 26 27
27 28 29 30 31            24 25 26 27 28 29 30      28 29 30
                          31

      October                   November                  December
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
          1  2  3  4                         1          1  2  3  4  5  6
 5  6  7  8  9 10 11       2  3  4  5  6  7  8       7  8  9 10 11 12 13
12 13 14 15 16 17 18       9 10 11 12 13 14 15      14 15 16 17 18 19 20
19 20 21 22 23 24 25      16 17 18 19 20 21 22      21 22 23 24 25 26 27
26 27 28 29 30 31         23 24 25 26 27 28 29      28 29 30 31
                          30

Now look at the documentation of the calendar module to find out about
other options.

Marco
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to