OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33
Information System : Linux apprendre2 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
Wrapper class providing the various date and number formatting functions
bound to a specific locale and time-zone. Inherited from Inherited from Return a date formatted according to the given pattern. See Also:
babel.dates.format_date
Return a date and time formatted according to the given pattern. See Also:
babel.dates.format_datetime
Return a time formatted according to the given pattern. See Also:
babel.dates.format_time
Return an integer number formatted for the locale. See Also:
babel.numbers.format_number
Return a decimal number formatted for the locale. See Also:
babel.numbers.format_decimal
See Also:
babel.numbers.format_currency
Return a number formatted as percentage for the locale. See Also:
babel.numbers.format_percent
See Also:
babel.numbers.format_scientific
Home
Trees
Indices
Help
Documentation Index
Class Format
object --+
|
Format
>>> fmt = Format('en_US', UTC)
>>> fmt.date(date(2007, 4, 1))
u'Apr 1, 2007'
>>> fmt.decimal(1.2345)
u'1.234'
Instance Methods
__init__(self,
locale,
tzinfo=None)
Initialize the formatter.
date(self,
date=None,
format=
'medium')
Return a date formatted according to the given pattern.
datetime(self,
datetime=None,
format=
'medium')
Return a date and time formatted according to the given pattern.
time(self,
time=None,
format=
'medium')
Return a time formatted according to the given pattern.
number(self,
number)
Return an integer number formatted for the locale.
decimal(self,
number,
format=None)
Return a decimal number formatted for the locale.
currency(self,
number,
currency)
Return a number in the given currency formatted for the locale.
percent(self,
number,
format=None)
Return a number formatted as percentage for the locale.
scientific(self,
number)
Return a number formatted using scientific notation for the locale.
object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__repr__,
__setattr__,
__sizeof__,
__str__,
__subclasshook__
Properties
object:
__class__
Method Details
Initialize the formatter.
__init__(self,
locale,
tzinfo=None)
(Constructor)
locale - the locale identifier or Locale instancetzinfo - the time-zone info (a tzinfo instance or None)
date(self,
date=None,
format=
'medium')
>>> fmt = Format('en_US')
>>> fmt.date(date(2007, 4, 1))
u'Apr 1, 2007'
datetime(self,
datetime=None,
format=
'medium')
>>> 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'
time(self,
time=None,
format=
'medium')
>>> from pytz import timezone
>>> fmt = Format('en_US', tzinfo=timezone('US/Eastern'))
>>> fmt.time(datetime(2007, 4, 1, 15, 30))
u'11:30:00 AM'
number(self,
number)
>>> fmt = Format('en_US')
>>> fmt.number(1099)
u'1,099'
decimal(self,
number,
format=None)
>>> fmt = Format('en_US')
>>> fmt.decimal(1.2345)
u'1.234'
Return a number in the given currency formatted for the locale.
currency(self,
number,
currency)
percent(self,
number,
format=None)
>>> fmt = Format('en_US')
>>> fmt.percent(0.34)
u'34%'
Return a number formatted using scientific notation for the locale.
scientific(self,
number)
Home
Trees
Indices
Help
Documentation Index
Generated by Epydoc 3.0.1 on Thu Mar 17 15:12:45 2011
http://epydoc.sourceforge.net