[Python-checkins] CVS: python/dist/src/Lib calendar.py,1.21,1.22
Barry Warsaw
bwarsaw@users.sourceforge.net
Tue, 22 May 2001 08:58:32 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv28926
Modified Files:
calendar.py
Log Message:
Application of patch #401842 by Denis S. Otkidach to support
localization of month and day names.
Index: calendar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** calendar.py 2001/01/20 19:54:20 1.21
--- calendar.py 2001/05/22 15:58:30 1.22
***************
*** 9,13 ****
# Import functions and variables from time module
! from time import localtime, mktime
__all__ = ["error","setfirstweekday","firstweekday","isleap",
--- 9,13 ----
# Import functions and variables from time module
! from time import localtime, mktime, strftime
__all__ = ["error","setfirstweekday","firstweekday","isleap",
***************
*** 25,39 ****
mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
# Full and abbreviated names of weekdays
! day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
! 'Friday', 'Saturday', 'Sunday']
! day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
# Full and abbreviated names of months (1-based arrays!!!)
! month_name = ['', 'January', 'February', 'March', 'April',
! 'May', 'June', 'July', 'August',
! 'September', 'October', 'November', 'December']
! month_abbr = [' ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
! 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# Constants for weekdays
--- 25,41 ----
mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+ class _localized_name:
+ def __init__(self, format):
+ self.format = format
+ def __getitem__(self, item):
+ return strftime(self.format, (item,)*9).capitalize()
+
# Full and abbreviated names of weekdays
! day_name = _localized_name('%A')
! day_abbr = _localized_name('%a')
# Full and abbreviated names of months (1-based arrays!!!)
! month_name = _localized_name('%B')
! month_abbr = _localized_name('%b')
# Constants for weekdays