# HG changeset patch # User cmlenz # Date 1216140482 0 # Node ID bc9b22b72ff796c86d8b3cad3e1e4313db75ec3f # Parent a11564c5c1f181b0e047f8f294b20fad44cce666 Ported [436] to 0.9.x branch. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Version 0.9.4 +http://svn.edgewall.org/repos/babel/tags/0.9.4/ +(???, from branches/stable/0.9.x) + + * Currency symbol definitions that is defined with choice patterns in the + CLDR data are no longer imported, so the symbol code will be used instead. + * Fixed quarter support in date formatting. + + Version 0.9.3 http://svn.edgewall.org/repos/babel/tags/0.9.3/ (Jul 9 2008, from branches/stable/0.9.x) diff --git a/babel/dates.py b/babel/dates.py --- a/babel/dates.py +++ b/babel/dates.py @@ -777,6 +777,14 @@ year = year[-2:] return year + def format_quarter(self, char, num): + quarter = (self.value.month - 1) // 3 + 1 + if num <= 2: + return ('%%0%dd' % num) % quarter + width = {3: 'abbreviated', 4: 'wide', 5: 'narrow'}[num] + context = {'Q': 'format', 'q': 'stand-alone'}[char] + return get_quarter_names(width, context, self.locale)[quarter] + def format_month(self, char, num): if num <= 2: return ('%%0%dd' % num) % self.value.month diff --git a/babel/tests/dates.py b/babel/tests/dates.py --- a/babel/tests/dates.py +++ b/babel/tests/dates.py @@ -22,6 +22,15 @@ class DateTimeFormatTestCase(unittest.TestCase): + def test_quarter_format(self): + d = date(2006, 6, 8) + fmt = dates.DateTimeFormat(d, locale='en_US') + self.assertEqual('2', fmt['Q']) + self.assertEqual('2nd quarter', fmt['QQQQ']) + d = date(2006, 12, 31) + fmt = dates.DateTimeFormat(d, locale='en_US') + self.assertEqual('Q4', fmt['QQQ']) + def test_month_context(self): d = date(2006, 1, 8) fmt = dates.DateTimeFormat(d, locale='cs_CZ')