|
|
|
@ -646,7 +646,7 @@ class Formatter extends Component
|
|
|
|
|
* PHP [date()](http://php.net/manual/en/function.date.php)-function. |
|
|
|
|
* |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value can not be evaluated as a date value. |
|
|
|
|
* @throws InvalidArgumentException if the input value can not be evaluated as a date value. |
|
|
|
|
* @throws InvalidConfigException if the date format is invalid. |
|
|
|
|
* @see timeFormat |
|
|
|
|
*/ |
|
|
|
@ -802,7 +802,7 @@ class Formatter extends Component
|
|
|
|
|
* the timestamp has time information or it is just a date value. |
|
|
|
|
* Since version 2.0.12 the array has third boolean element indicating whether the timestamp has date information |
|
|
|
|
* or it is just a time value. |
|
|
|
|
* @throws InvalidParamException if the input value can not be evaluated as a date value. |
|
|
|
|
* @throws InvalidArgumentException if the input value can not be evaluated as a date value. |
|
|
|
|
*/ |
|
|
|
|
protected function normalizeDatetimeValue($value, $checkDateTimeInfo = false) |
|
|
|
|
{ |
|
|
|
@ -1167,7 +1167,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
*/ |
|
|
|
|
public function asScientific($value, $decimals = null, $options = [], $textOptions = []) |
|
|
|
|
{ |
|
|
|
@ -1179,7 +1179,7 @@ class Formatter extends Component
|
|
|
|
|
if ($this->_intlLoaded) { |
|
|
|
|
$f = $this->createNumberFormatter(NumberFormatter::SCIENTIFIC, $decimals, $options, $textOptions); |
|
|
|
|
if (($result = $f->format($value)) === false) { |
|
|
|
|
throw new InvalidParamException('Formatting scientific number value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage()); |
|
|
|
|
throw new InvalidArgumentException('Formatting scientific number value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
@ -1204,7 +1204,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidConfigException if no currency is given and [[currencyCode]] is not defined. |
|
|
|
|
*/ |
|
|
|
|
public function asCurrency($value, $currency = null, $options = [], $textOptions = []) |
|
|
|
@ -1228,7 +1228,7 @@ class Formatter extends Component
|
|
|
|
|
$result = $formatter->formatCurrency($value, $currency); |
|
|
|
|
} |
|
|
|
|
if ($result === false) { |
|
|
|
|
throw new InvalidParamException('Formatting currency value failed: ' . $formatter->getErrorCode() . ' ' . $formatter->getErrorMessage()); |
|
|
|
|
throw new InvalidArgumentException('Formatting currency value failed: ' . $formatter->getErrorCode() . ' ' . $formatter->getErrorMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
@ -1251,7 +1251,7 @@ class Formatter extends Component
|
|
|
|
|
* |
|
|
|
|
* @param mixed $value the value to be formatted |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidConfigException when the [PHP intl extension](http://php.net/manual/en/book.intl.php) is not available. |
|
|
|
|
*/ |
|
|
|
|
public function asSpellout($value) |
|
|
|
@ -1263,7 +1263,7 @@ class Formatter extends Component
|
|
|
|
|
if ($this->_intlLoaded) { |
|
|
|
|
$f = $this->createNumberFormatter(NumberFormatter::SPELLOUT); |
|
|
|
|
if (($result = $f->format($value)) === false) { |
|
|
|
|
throw new InvalidParamException('Formatting number as spellout failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage()); |
|
|
|
|
throw new InvalidArgumentException('Formatting number as spellout failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
@ -1279,7 +1279,7 @@ class Formatter extends Component
|
|
|
|
|
* |
|
|
|
|
* @param mixed $value the value to be formatted |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidConfigException when the [PHP intl extension](http://php.net/manual/en/book.intl.php) is not available. |
|
|
|
|
*/ |
|
|
|
|
public function asOrdinal($value) |
|
|
|
@ -1291,7 +1291,7 @@ class Formatter extends Component
|
|
|
|
|
if ($this->_intlLoaded) { |
|
|
|
|
$f = $this->createNumberFormatter(NumberFormatter::ORDINAL); |
|
|
|
|
if (($result = $f->format($value)) === false) { |
|
|
|
|
throw new InvalidParamException('Formatting number as ordinal failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage()); |
|
|
|
|
throw new InvalidArgumentException('Formatting number as ordinal failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
@ -1313,7 +1313,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @see sizeFormatBase |
|
|
|
|
* @see asSize |
|
|
|
|
*/ |
|
|
|
@ -1424,7 +1424,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $numberOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidConfigException when INTL is not installed or does not contain required information. |
|
|
|
|
* @see asLength |
|
|
|
|
* @since 2.0.13 |
|
|
|
@ -1447,7 +1447,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidConfigException when INTL is not installed or does not contain required information. |
|
|
|
|
* @see asLength |
|
|
|
|
* @since 2.0.13 |
|
|
|
@ -1468,7 +1468,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidConfigException when INTL is not installed or does not contain required information. |
|
|
|
|
* @since 2.0.13 |
|
|
|
|
* @author John Was <janek.jan@gmail.com> |
|
|
|
@ -1490,7 +1490,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return string the formatted result. |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidConfigException when INTL is not installed or does not contain required information. |
|
|
|
|
* @since 2.0.13 |
|
|
|
|
* @author John Was <janek.jan@gmail.com> |
|
|
|
@ -1597,7 +1597,7 @@ class Formatter extends Component
|
|
|
|
|
* @param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
|
|
|
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
|
|
|
|
* @return array [parameters for Yii::t containing formatted number, internal position of size unit] |
|
|
|
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed. |
|
|
|
|
* @throws InvalidArgumentException if the input value is not numeric or the formatting failed. |
|
|
|
|
*/ |
|
|
|
|
private function formatNumber($value, $decimals, $maxPosition, $formatBase, $options, $textOptions) |
|
|
|
|
{ |
|
|
|
|