variant, if those are specified.
>>> Locale('zh', 'CN', script='Hans').get_display_name('en')
- u'Chinese (Simplified Han, China)'
+ u'Chinese (Simplified, China)'
:param locale: the locale to use
:return: the display name
>>> Locale('en', 'US').time_zones['Europe/London']['long']['daylight']
u'British Summer Time'
>>> Locale('en', 'US').time_zones['America/St_Johns']['city']
- u"St. John's"
+ u'St. John\u2019s'
:type: `dict`"""
return self._data['time_zones']
>>> from pytz import timezone
>>> tz = timezone('America/St_Johns')
>>> get_timezone_location(tz, locale='de_DE')
- u"Kanada (St. John's)"
+ u"Kanada (St. John's) Zeit"
>>> tz = timezone('America/Mexico_City')
>>> get_timezone_location(tz, locale='de_DE')
- u'Mexiko (Mexiko-Stadt)'
+ u'Mexiko (Mexiko-Stadt) Zeit'
If the timezone is associated with a country that uses only a single
timezone, just the localized country name is returned:
>>> tz = timezone('Europe/Berlin')
>>> get_timezone_name(tz, locale='de_DE')
- u'Deutschland'
+ u'Mitteleurop\\xe4ische Zeit'
:param dt_or_tzinfo: the ``datetime`` or ``tzinfo`` object that determines
the timezone; if `None`, the current date and time in
>>> dt = datetime(2007, 04, 01, 15, 30)
>>> format_datetime(dt, locale='en_US')
- u'Apr 1, 2007 3:30:00 PM'
+ u'Apr 1, 2007, 3:30:00 PM'
For any pattern requiring the display of the time-zone, the third-party
``pytz`` package is needed to explicitly specify the time-zone:
>>> from pytz import timezone
>>> format_datetime(dt, 'full', tzinfo=timezone('Europe/Paris'),
... locale='fr_FR')
- u'dimanche 1 avril 2007 17:30:00 Heure avanc\xe9e de l\u2019Europe centrale'
+ u'dimanche 1 avril 2007 17:30:00 heure avanc\xe9e d\u2019Europe centrale'
>>> format_datetime(dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz",
... tzinfo=timezone('US/Eastern'), locale='en')
u'2007.04.01 AD at 11:30:00 EDT'
>>> from pytz import timezone
>>> fmt = Format('en_US', tzinfo=timezone('US/Eastern'))
>>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
- u'Apr 1, 2007 11:30:00 AM'
+ u'Apr 1, 2007, 11:30:00 AM'
:see: `babel.dates.format_datetime`
"""
tz = timezone('Europe/Paris')
t = time(15, 30, tzinfo=tz)
fmt = dates.DateTimeFormat(t, locale='fr_FR')
- self.assertEqual(u'Heure de l\u2019Europe centrale', fmt['vvvv'])
+ self.assertEqual(u'heure de l\u2019Europe centrale', fmt['vvvv'])
def test_hour_formatting(self):
l = 'en_US'