summaryrefslogtreecommitdiffstats
path: root/Lib/calendar.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-05-22 15:58:30 (GMT)
committerBarry Warsaw <barry@python.org>2001-05-22 15:58:30 (GMT)
commit1d099103d87ac0ea6fef78f92705740051b14ed0 (patch)
tree28bd012e1b52941f927e2f2830294cdc110f65b7 /Lib/calendar.py
parentd0b625d05aacd47184b453c9bf46f1792e3d5eae (diff)
downloadcpython-1d099103d87ac0ea6fef78f92705740051b14ed0.zip
cpython-1d099103d87ac0ea6fef78f92705740051b14ed0.tar.gz
cpython-1d099103d87ac0ea6fef78f92705740051b14ed0.tar.bz2
Application of patch #401842 by Denis S. Otkidach to support
localization of month and day names.
Diffstat (limited to 'Lib/calendar.py')
-rw-r--r--Lib/calendar.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py
index 2efb1c4..0fc60be 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -8,7 +8,7 @@ set the first day of the week (0=Monday, 6=Sunday)."""
# Revision 2: uses functions from built-in time module
# Import functions and variables from time module
-from time import localtime, mktime
+from time import localtime, mktime, strftime
__all__ = ["error","setfirstweekday","firstweekday","isleap",
"leapdays","weekday","monthrange","monthcalendar",
@@ -24,17 +24,19 @@ February = 2
# Number of days per month (except for February in leap years)
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 = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
- 'Friday', 'Saturday', 'Sunday']
-day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+day_name = _localized_name('%A')
+day_abbr = _localized_name('%a')
# 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']
+month_name = _localized_name('%B')
+month_abbr = _localized_name('%b')
# Constants for weekdays
(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7)