Mercurial > babel > mirror
comparison babel/tests/dates.py @ 29:72bf45adb926 trunk
More work on timezones.
author | cmlenz |
---|---|
date | Mon, 04 Jun 2007 10:51:38 +0000 |
parents | d8352fbaca65 |
children | 13d69e50fc3a |
comparison
equal
deleted
inserted
replaced
28:b00b06e5ace8 | 29:72bf45adb926 |
---|---|
12 # history and logs, available at http://babel.edgewall.org/log/. | 12 # history and logs, available at http://babel.edgewall.org/log/. |
13 | 13 |
14 from datetime import date, datetime, time | 14 from datetime import date, datetime, time |
15 import doctest | 15 import doctest |
16 import unittest | 16 import unittest |
17 | |
18 from pytz import timezone | |
17 | 19 |
18 from babel import dates | 20 from babel import dates |
19 | 21 |
20 | 22 |
21 class DateTimeFormatTestCase(unittest.TestCase): | 23 class DateTimeFormatTestCase(unittest.TestCase): |
52 fmt = dates.DateTimeFormat(d, locale='en_US') | 54 fmt = dates.DateTimeFormat(d, locale='en_US') |
53 self.assertEqual('2', fmt['c']) # sunday is first day of week | 55 self.assertEqual('2', fmt['c']) # sunday is first day of week |
54 fmt = dates.DateTimeFormat(d, locale='dv_MV') | 56 fmt = dates.DateTimeFormat(d, locale='dv_MV') |
55 self.assertEqual('4', fmt['c']) # friday is first day of week | 57 self.assertEqual('4', fmt['c']) # friday is first day of week |
56 | 58 |
59 def test_timezone_rfc822(self): | |
60 tz = timezone('Europe/Berlin') | |
61 t = time(15, 30, tzinfo=tz) | |
62 fmt = dates.DateTimeFormat(t, locale='de_DE') | |
63 self.assertEqual('+0100', fmt['Z']) | |
64 | |
65 def test_timezone_gmt(self): | |
66 tz = timezone('Europe/Berlin') | |
67 t = time(15, 30, tzinfo=tz) | |
68 fmt = dates.DateTimeFormat(t, locale='de_DE') | |
69 self.assertEqual('GMT +01:00', fmt['ZZZZ']) | |
70 | |
71 | |
57 | 72 |
58 class FormatDateTestCase(unittest.TestCase): | 73 class FormatDateTestCase(unittest.TestCase): |
59 | 74 |
60 def test_with_time_fields_in_pattern(self): | 75 def test_with_time_fields_in_pattern(self): |
61 self.assertRaises(AttributeError, dates.format_date, date(2007, 04, 01), | 76 self.assertRaises(AttributeError, dates.format_date, date(2007, 04, 01), |