codehaus


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

questions re: calendar module


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'!

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

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?

What do you think?


Further web.refs:
Working with Python Calendar in Depth
https://www.pythonpool.com/python-calendar/

Python CALENDAR Tutorial with Example
https://www.guru99.com/calendar-in-python.html
-- 
Regards =dn