Application of patch #401842 by Denis S. Otkidach to support
localization of month and day names.
This commit is contained in:
parent
d0b625d05a
commit
1d099103d8
|
@ -8,7 +8,7 @@ set the first day of the week (0=Monday, 6=Sunday)."""
|
||||||
# Revision 2: uses functions from built-in time module
|
# Revision 2: uses functions from built-in time module
|
||||||
|
|
||||||
# Import functions and variables from 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",
|
__all__ = ["error","setfirstweekday","firstweekday","isleap",
|
||||||
"leapdays","weekday","monthrange","monthcalendar",
|
"leapdays","weekday","monthrange","monthcalendar",
|
||||||
|
@ -24,17 +24,19 @@ February = 2
|
||||||
# Number of days per month (except for February in leap years)
|
# 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]
|
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
|
# Full and abbreviated names of weekdays
|
||||||
day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
|
day_name = _localized_name('%A')
|
||||||
'Friday', 'Saturday', 'Sunday']
|
day_abbr = _localized_name('%a')
|
||||||
day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
||||||
|
|
||||||
# Full and abbreviated names of months (1-based arrays!!!)
|
# Full and abbreviated names of months (1-based arrays!!!)
|
||||||
month_name = ['', 'January', 'February', 'March', 'April',
|
month_name = _localized_name('%B')
|
||||||
'May', 'June', 'July', 'August',
|
month_abbr = _localized_name('%b')
|
||||||
'September', 'October', 'November', 'December']
|
|
||||||
month_abbr = [' ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
|
||||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
||||||
|
|
||||||
# Constants for weekdays
|
# Constants for weekdays
|
||||||
(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7)
|
(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7)
|
||||||
|
|
Loading…
Reference in New Issue