[Patches] [Patch #101085] calendar.py extensions

noreply@sourceforge.net noreply@sourceforge.net
Wed, 30 Aug 2000 07:02:57 -0700


Patch #101085 has been updated. 

Project: 
Category: Modules
Status: Closed
Summary: calendar.py extensions

Follow-Ups:

Date: 2000-Aug-05 18:54
By: goodger

Comment:
(1) Allows any weekday to start a week, not just Monday as hardcoded. (2) Added functions which return week, month and year calendars as strings (e.g. prmonth() prints, month() returns string), so we aren't forced to play with stdout when we don't want to print. Had to modify some (manditory, therefore non-keyword) parameters in prweek(), prmonth() & prcal()'s signatures. (3) Removed "caching interface to _monthcalendar" as unnecessary complexity.

-------------------------------------------------------

Date: 2000-Aug-15 12:05
By: tim_one

Comment:
Assigned to Skip because he's a Calendar kind of fellow.  Please review or pass on to someone else.
-------------------------------------------------------

Date: 2000-Aug-17 13:16
By: montanaro

Comment:
Looks reasonable with the following recommendations and questions:

    * the w (width) and l (length) keyword args to month and
      prmonth should probably be called something else
      (columnwidth and rowheight perhaps?).  Should
      calendar/prcal have columnwidth, rowheight and
      gutterwidth optional arguments?

    * I think the month() function should include a trailing
      newline and that prmonth should call sys.stdout.write.
      Same for the calendar/prcal pair.

    * Should firstweekday accept string arguments as well
      so people don't have to map from days of the week to
      integers?  What does this imply for locales?  Can
      English just be assumed?


-------------------------------------------------------

Date: 2000-Aug-17 13:21
By: montanaro

Comment:
Just occurred to me...  Perhaps firstweekday() should 
reset to the default for the module (Monday) instead of
the US convention (Sunday first).


-------------------------------------------------------

Date: 2000-Aug-23 19:20
By: montanaro

Comment:
sent note to David asking about progress on an updated patch.
-------------------------------------------------------

Date: 2000-Aug-23 21:16
By: goodger

Comment:
1:
Skip Montanaro ("SM") writes:
SM> * the w (width) and l (length) keyword args to month and 
SM> prmonth should probably be called something else 
SM> (columnwidth and rowheight perhaps?)

This would break backwards compatibility on
prmonth() with keyword arguments.

2:
SM> * I think the month() function should include a trailing 
SM> newline and that prmonth should call sys.stdout.write. 
SM> Same for the calendar/prcal pair. 

Newlines: Yes, will do.

sys.stdout.write: Why? What advantage would that have
over 'print month(theyear, ...),' (note the trailing
comma)?

3:
SM> * Should firstweekday accept string arguments as well 
SM> so people don't have to map from days of the week to 
SM> integers? What does this imply for locales? Can 
SM> English just be assumed? 

Supporting locales would entail a much more ambitious
patch (perhaps a complete rewrite). Realistically
speaking, I don't think it's worth it. Perhaps an
enumeration instead? I've added:

    (Monday, Tuesday, Wednesday, Thursday, Friday, 
     Saturday, Sunday) = range(7)

4:
SM> Perhaps firstweekday() should 
SM> reset to the default for the module (Monday) instead of 
SM> the US convention (Sunday first). 

Since Monday is the default upon importing the module,
nobody would call firstweekday() unless they wanted to
change it. I will drop the default altogether, rather
than forcing behaviour.

-------------------------------------------------------

Date: 2000-Aug-23 21:18
By: goodger

Comment:
4:
SM>I imagine you're correct.  I was thinking about the case where someone wants
SM>to fiddle the starting day of the week, then restore it:

SM>Maybe firstweekday should return the previous value.

I've renamed the setting function to setfirstweekday(weekday), and now
firstweekday() returns the current setting. I think its better to keep 
functional and procedural (side-effect) separate.

-------------------------------------------------------

Date: 2000-Aug-26 14:13
By: goodger

Comment:
Revised patch: modified convenience weekday enumeration values to uppercase, as per Python library module standards for constants.
-------------------------------------------------------

Date: 2000-Aug-30 07:02
By: montanaro

Comment:
accepted and checked in

-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=101085&group_id=5470