[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/i18n/ -> sfNumberFormat.class.php (sommaire)

sfNumberFormat class file. This program is free software; you can redistribute it and/or modify it under the terms of the BSD License.

Author: Wei Zhuo
Version: $Id: sfNumberFormat.class.php 2834 2006-11-27 14:09:05Z fabien $
Poids: 316 lignes (8 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

sfNumberFormat:: (5 méthodes):
  __construct()
  format()
  formatInteger()
  formatDecimal()
  setPattern()


Classe: sfNumberFormat  - X-Ref

sfNumberFormat class.

sfNumberFormat formats decimal numbers in any locale. The decimal
number is formatted according to a particular pattern. These
patterns can arise from the sfNumberFormatInfo object which is
culturally sensitive. The sfNumberFormat class can be instantiated in
many ways. E.g.

<code>
//create a invariant number formatter.
$formatter = new sfNumberFormat();

//create a number format for the french language locale.
$fr = new sfNumberFormat('fr');

//create a number format base on a sfNumberFormatInfo instance $numberInfo.
$format = new sfNumberFormat($numberInfo);
</code>

A normal decimal number can also be displayed as a currency
or as a percentage. For example
<code>
$format->format(1234.5); //Decimal number "1234.5"
$format->format(1234.5,'c'); //Default currency "$1234.50"
$format->format(0.25, 'p') //Percent "25%"
</code>

Currency is formated using the localized currency pattern. For example
to format the number as Japanese Yen:
<code>
$ja = new sfNumberFormat('ja_JP');

//Japanese currency pattern, and using Japanese Yen symbol
$ja->format(123.14,'c','JPY'); //ï¿?123 (Yen 123)
</code>
For each culture, the symbol for each currency may be different.

__construct($formatInfo = null)   X-Ref
Create a new number format instance. The constructor can be instantiated
with a string that represent a culture/locale. Similarly, passing
a sfCultureInfo or sfNumberFormatInfo instance will instantiated a instance
for that particular culture.

param: mixed either null, a sfCultureInfo, a sfNumberFormatInfo, or string
return: sfNumberFormat

format($number, $pattern = 'd', $currency = 'USD', $charset = 'UTF-8')   X-Ref
For the number for a certain pattern. The valid patterns are
'c', 'd', 'e', 'p' or a custom pattern, such as "#.000" for
3 decimal places.

param: mixed the number to format.
param: string the format pattern, either, 'c', 'd', 'e', 'p'
param: string 3-letter ISO 4217 code. For example, the code
return: string formatted number string

formatInteger($string)   X-Ref
For the integer, perform groupings and string padding.

param: string the decimal number in string form.
return: string  formatted integer string with grouping

formatDecimal($string)   X-Ref
Format the decimal places.

param: string the decimal number in string form.
return: string formatted decimal places.

setPattern($pattern)   X-Ref
Set the pattern to format against. The default patterns
are retrieved from the sfNumberFormatInfo instance.

param: string the requested patterns.
return: string a number format pattern.



Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7