codehaus


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

questions re: calendar module


On Sat, Aug 1, 2020 at 6:29 PM dn via Python-list
<python-list at python.org> wrote:
>
> On 01/08/2020 23:36, o1bigtenor wrote:
> > On Sat, Aug 1, 2020 at 1:29 AM dn via Python-list
> > <python-list at python.org <mailto:python-list at python.org>> wrote:
> >
> >     On 31/07/2020 02:52, o1bigtenor wrote:
> >      > I regularly work in planning through multiple years at once.
> >      > This means that I like to have a lot of stuff available in a calendar
> >      > function.
> >      > Python seems to be locked when I need to display more than 1 year
> >     at a
> >      > time.
> >      > I don't see a way to display something like 3 years worth of calendar
> >      > starting at a point 23 months from now.
> >      > (I see how to display 1 year at a time but not multiple years.)
> >
> >     This question seems a little vague. How are you creating this "calendar
> >     function"? Are you using the Python Standard Library calendar, or
> >     perhaps talking about datetime calculations?
> >
> >     Please copy-paste code showing this "lock".
> >
> >
> > Maybe its not a lock - - - - but there seems to be no way to display a
> > calendar starting
> > from a date that is 3 years in time frame.
> ...
>
> > I would like to show something like 2024 through the end of 2028.
>
>
> Let's start with the disappointing information:-
> - please read https://docs.python.org/3/library/calendar.html and the
> *function's* help:
>
>  >>> help(cal.calendar)
> Help on method formatyear in module calendar:
> formatyear(theyear, w=2, l=1, c=6, m=3) method of calendar.TextCalendar
> instance
>      Returns a year's calendar as a multi-line string.
>
> The word "year" is singular, and the parameters are all to do with the
> output-presentation. We can't even request 'the rest of the year from
> August onwards'!

It is very disappointing - - - -suggests that thinking outside the space of
one year is somehow deprecated. Frustrated when what you do demands
that you think in longer periods of time (and yet have to function within
the week as well).

>
> There are other helper functions. Also, we are invited to sub-class.

Hmmmmmm - - - will have to investigate that.
>
> Might it be possible to generate multiple year (or month) groups, split
> them by line, and then reassemble line-by-line to produce the width and
> temporal length required?

Likely work well if the months were considered as discrete blocks.
Thinking that one could have something like

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

It is very useful for me to have the week numbers included. Have
learned some fascinating things (some months have 6 weeks in
them!) and the joys of formating (grin!).
>
> What do you think?

I was starting from what I understood (how to print 'a' year) working
to get closer to what I could use. Ncal allows me to display a
calendar except I'm restricted to a display only 3 months wide. More
than one month is relatively easy to display from present but not
from some other point. It would seem that the 80 column display
still rules supreme - - - - - and that's on a 1920 pixel wide monitor.

Thanks for the ideas and suggestions!