Пример #1
0
 function testLocalizedPatterns()
 {
     $fr = NumberFormatInfo::getInstance('fr');
     $de = NumberFormatInfo::getInstance('de');
     $en = NumberFormatInfo::getInstance('en_US');
     $this->assertEquals($fr->DecimalSeparator, ',');
     $this->assertEquals($de->DecimalSeparator, ',');
     $this->assertEquals($en->DecimalSeparator, '.');
     $this->assertEquals($fr->GroupSeparator, ' ');
     $this->assertEquals($de->GroupSeparator, '.');
     $this->assertEquals($en->GroupSeparator, ',');
 }
Пример #2
0
 /**
  * Create a new number format instance. The constructor can be instantiated
  * with a string that represent a culture/locale. Similarly, passing
  * a CultureInfo or NumberFormatInfo instance will instantiated a instance
  * for that particular culture.
  * @param mixed either null, a CultureInfo, a NumberFormatInfo, or string
  * @return NumberFormat
  */
 function __construct($formatInfo = null)
 {
     if ($formatInfo === null) {
         $this->formatInfo = NumberFormatInfo::getInvariantInfo();
     } else {
         if ($formatInfo instanceof CultureInfo) {
             $this->formatInfo = $formatInfo->NumberFormat;
         } else {
             if ($formatInfo instanceof NumberFormatInfo) {
                 $this->formatInfo = $formatInfo;
             } else {
                 $this->formatInfo = NumberFormatInfo::getInstance($formatInfo);
             }
         }
     }
 }