]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to...
authorChristopher Lenz <cmlenz@gmail.com>
Mon, 16 Jun 2008 11:37:52 +0000 (11:37 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Mon, 16 Jun 2008 11:37:52 +0000 (11:37 +0000)
babel/dates.py
babel/tests/dates.py

index 74c7b846c06903936529fbfcd6715c2285243218..28f69decf2213eda18a0fa5fd813a1ae488232cc 100644 (file)
@@ -751,7 +751,7 @@ class DateTimeFormat(object):
         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):
index b213d19bd1e8d3dc3867826c4a6e967e6ff64a08..b06dd7b1a5391cbe63802d292603401aa87a2e3f 100644 (file)
@@ -22,6 +22,13 @@ from babel import dates
 
 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')