Babel versions.
>>> Locale('en', 'US').time_formats['short']
- <DateTimePattern 'h:mm\u202fa'>
+ <DateTimePattern 'h:mm\\u202fa'>
>>> Locale('fr', 'FR').time_formats['long']
<DateTimePattern 'HH:mm:ss z'>
"""
smallest changing component:
>>> Locale('fi_FI').interval_formats['MEd']['d']
- ['E d.\u2009–\u2009', 'E d.M.']
+ ['E d.\\u2009–\\u2009', 'E d.M.']
.. seealso::
format.
>>> get_time_format(locale='en_US')
- <DateTimePattern 'h:mm:ss\u202fa'>
+ <DateTimePattern 'h:mm:ss\\u202fa'>
>>> get_time_format('full', locale='de_DE')
<DateTimePattern 'HH:mm:ss zzzz'>
'12:12–16:16'
>>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US")
- '5:12\u202fAM\u2009–\u20094:16\u202fPM'
+ '5:12\\u202fAM\\u2009–\\u20094:16\\u202fPM'
>>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it")
'16:18–16:24'
'16:18:00~16:24:00'
>>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de")
- '15.01.2016\u2009–\u200917.01.2016'
+ '15.01.2016\\u2009–\\u200917.01.2016'
:param start: First instant (datetime/date/time)
:param end: Second instant (datetime/date/time)
>>> get_plus_sign_symbol('en_US')
'+'
>>> get_plus_sign_symbol('ar_EG', numbering_system='default')
- '\u061c+'
+ '\\u061c+'
>>> get_plus_sign_symbol('ar_EG', numbering_system='latn')
- '\u200e+'
+ '\\u200e+'
:param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
:param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
>>> get_minus_sign_symbol('en_US')
'-'
>>> get_minus_sign_symbol('ar_EG', numbering_system='default')
- '\u061c-'
+ '\\u061c-'
>>> get_minus_sign_symbol('ar_EG', numbering_system='latn')
- '\u200e-'
+ '\\u200e-'
:param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
:param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
>>> format_compact_decimal(21000000, format_type="long", locale="mk")
'21 милион'
>>> format_compact_decimal(12345, format_type="short", locale='ar_EG', fraction_digits=2, numbering_system='default')
- '12٫34\xa0ألف'
+ '12٫34\\xa0ألف'
:param number: the number to format
:param format_type: Compact format to use ("short" or "long")
>>> format_currency(1099.98, 'EUR', locale='de_DE')
'1.099,98\\xa0\\u20ac'
>>> format_currency(1099.98, 'EGP', locale='ar_EG', numbering_system='default')
- '\u200f1٬099٫98\xa0ج.م.\u200f'
+ '\\u200f1٬099٫98\\xa0ج.م.\\u200f'
The format can also be specified explicitly. The currency is
placed with the '¤' sign. As the sign gets repeated the format
expands (¤ being the symbol, ¤¤ is the currency abbreviation and
¤¤¤ is the full name of the currency):
- >>> format_currency(1099.98, 'EUR', '\xa4\xa4 #,##0.00', locale='en_US')
+ >>> format_currency(1099.98, 'EUR', '\\xa4\\xa4 #,##0.00', locale='en_US')
'EUR 1,099.98'
- >>> format_currency(1099.98, 'EUR', '#,##0.00 \xa4\xa4\xa4', locale='en_US')
+ >>> format_currency(1099.98, 'EUR', '#,##0.00 \\xa4\\xa4\\xa4', locale='en_US')
'1,099.98 euros'
Currencies usually have a specific number of decimal digits. This function
>>> format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2)
'$123.46M'
>>> format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1)
- '123,5\xa0Mio.\xa0€'
+ '123,5\\xa0Mio.\\xa0€'
:param number: the number to format
:param currency: the currency code
The format pattern can also be specified explicitly:
- >>> format_percent(25.1234, '#,##0\u2030', locale='en_US')
+ >>> format_percent(25.1234, '#,##0\\u2030', locale='en_US')
'25,123‰'
By default the locale is allowed to truncate and round a high-precision
>>> from babel.dates import get_timezone
>>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
>>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
- 'Apr 1, 2007, 11:30:00\u202fAM'
+ 'Apr 1, 2007, 11:30:00\\u202fAM'
"""
return format_datetime(datetime, format, tzinfo=self.tzinfo, locale=self.locale)
>>> from babel.dates import get_timezone
>>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
>>> fmt.time(datetime(2007, 4, 1, 15, 30))
- '11:30:00\u202fAM'
+ '11:30:00\\u202fAM'
"""
return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)