diff options
Diffstat (limited to 'django/utils/dateformat.py')
| -rw-r--r-- | django/utils/dateformat.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py index 00eb9fe617..a558e3a69f 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -13,10 +13,11 @@ Usage: from django.utils.dates import MONTHS, MONTHS_3, MONTHS_AP, WEEKDAYS from django.utils.tzinfo import LocalTimezone +from django.utils.translation import gettext as _ from calendar import isleap, monthrange import re, time -re_formatchars = re.compile(r'(?<!\\)([aABdDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])') +re_formatchars = re.compile(r'(?<!\\)([aAbBdDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])') re_escaped = re.compile(r'\\(.)') class Formatter(object): @@ -36,14 +37,14 @@ class TimeFormat(Formatter): def a(self): "'a.m.' or 'p.m.'" if self.data.hour > 11: - return 'p.m.' - return 'a.m.' + return _('p.m.') + return _('a.m.') def A(self): "'AM' or 'PM'" if self.data.hour > 11: - return 'PM' - return 'AM' + return _('PM') + return _('AM') def B(self): "Swatch Internet time" @@ -91,9 +92,9 @@ class TimeFormat(Formatter): Proprietary extension. """ if self.data.minute == 0 and self.data.hour == 0: - return 'midnight' + return _('midnight') if self.data.minute == 0 and self.data.hour == 12: - return 'noon' + return _('noon') return '%s %s' % (self.f(), self.a()) def s(self): @@ -110,6 +111,10 @@ class DateFormat(TimeFormat): if hasattr(self.data, 'hour') and not self.timezone: self.timezone = LocalTimezone(dt) + def b(self): + "Month, textual, 3 letters, lowercase; e.g. 'jan'" + return MONTHS_3[self.data.month] + def d(self): "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'" return '%02d' % self.data.day |
