codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

questions re: calendar module


On Sat, Aug 1, 2020 at 9:29 AM o1bigtenor <o1bigtenor at gmail.com> wrote:
>
> On Sat, Aug 1, 2020 at 6:58 AM Peter Otten <__peter__ at web.de> wrote:
> >
> > o1bigtenor wrote:
> >
> > >>>> import calendar
> > >>>> print (calendar.calendar(2024,1,1,2,8))
> >
> > > I would like to show something like 2024 through the end of 2028.
> >
> > print("\n".join(cd.calendar(year) for year in range(2024, 2029)))
>
>
> Sorry - - - - 1st response was to only Mr Peter - - - hopefully this is
> useful to more than I so here is that to all.
> >
> >
>
> >>> print("\n".join(cd.calendar(year) for year in range(2024, 2029)))
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 1, in <genexpr>
> NameError: name 'cd' is not defined
>
> so 'cd' seems to be a problem.
>
> Tried changing 'cd' to calendar and that gives the desired response.
>
> Except its a neat 3 months wide very very very many rows of calendar.
>
> I'm trying to figure out how to do something like this:
>
>         November 2022                      December 2022
>     January 2023                    February 2023
> March 2023                        April 2023
> May 2023
>        Su Mo Tu We Th Fr Sa         Su Mo Tu We Th Fr Sa      Su Mo Tu
> We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa
> Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa
> 123        1  2  3  4  5             127              1  2  3
>     132  1  2  3  4  5  6  7  136           1  2  3  4  140
> 1  2  3  4  144                    1  149     1  2  3  4  5  6
> 124  6  7  8  9 10 11 12  128  4  5  6  7  8  9 10  133  8  9 10 11 12
> 13 14  137  5  6  7  8  9 10 11  141  5  6  7  8  9 10 11  145  2  3
> 4  5  6  7  8  150  7  8  9 10 11 12 13
> 125 13 14 15 16 17 18 19  129 11 12 13 14 15 16 17  134 15 16 17 18 19
> 20 21  138 12 13 14 15 16 17 18  142 12 13 14 15 16 17 18  146  9 10
> 11 12 13 14 15  151 14 15 16 17 18 19 20
> 126 20 21 22 23 24 25 26  130 18 19 20 21 22 23 24  135 22 23 24 25 26
> 27 28  139 19 20 21 22 23 24 25  143 19 20 21 22 23 24 25  147 16 17
> 18 19 20 21 22  152 21 22 23 24 25 26 27
> 127 27 28 29 30           131 25 26 27 28 29 30 31  136 29 30 31
>        140 26 27 28              144 26 27 28 29 30 31     148 23 24
> 25 26 27 28 29  153 28 29 30 31
>
>                                                            149 30
>
>        June 2023                 July 2023                August 2023
>            September 2023             October 2023
> November 2023             December 2023
>     Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th
> Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo
> Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa
> 153              1  2  3  157                    1  162        1  2  3
>  4  5  166                 1  2  171  1  2  3  4  5  6  7  175
>   1  2  3  4  179                 1  2
>
> The formatting here is a mess.

(Its an even bigger mess now when its truncated to 80 columns. Can't change
the mess but I can tell you that it doesn't 'look that way'! Don't know how to
include an example in the body and have it be even a bit accurate - - - please
advise if there is a way.)

> The months are centered. The week numbers are consecutive from the
> starting date.
> The dates are centered under the weekday name. If you've ever used
> ncal its like that except
> that I can now have up to 7 months wide if the terminal is wide enough
> (>180 columns IIRC).
> A mentor was working on this in Perl but as he died some couple months
> ago its up to me
> to make what I want.
> Because it seems like there are a lot of disparate things happening
> its not very straight
> forward trying to replicate and extend my friend's efforts except in
> Python. (My friend
> preferred to work in Perl rather than Python and I'm wanting to learn
> Python. I understand
> that this is not perhaps the easiest way to learn something but it
> sure is interesting!)
>
> TIA