changeset 344:eb12741b65df trunk

Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
author cmlenz
date Mon, 16 Jun 2008 11:37:52 +0000
parents 9c718e8af219
children e818b03b370f
files babel/dates.py babel/tests/dates.py
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/babel/dates.py
+++ b/babel/dates.py
@@ -751,7 +751,7 @@
         if num <= 2:
             return ('%%0%dd' % num) % self.value.month
         width = {3: 'abbreviated', 4: 'wide', 5: 'narrow'}[num]
-        context = {3: 'format', 4: 'format', 5: 'stand-alone'}[num]
+        context = {'M': 'format', 'L': 'stand-alone'}[char]
         return get_month_names(width, context, self.locale)[self.value.month]
 
     def format_week(self, char, num):
--- a/babel/tests/dates.py
+++ b/babel/tests/dates.py
@@ -22,6 +22,13 @@
 
 class DateTimeFormatTestCase(unittest.TestCase):
 
+    def test_month_context(self):
+        d = date(2006, 1, 8)
+        fmt = dates.DateTimeFormat(d, locale='cs_CZ')
+        self.assertEqual('1', fmt['MMM'])
+        fmt = dates.DateTimeFormat(d, locale='cs_CZ')
+        self.assertEqual('1.', fmt['LLL'])
+
     def test_week_of_year_first(self):
         d = date(2006, 1, 8)
         fmt = dates.DateTimeFormat(d, locale='de_DE')
Copyright (C) 2012-2017 Edgewall Software