Browse Source

Better Formatter error handler

tags/2.0.0-beta
Alexander Makarov 11 years ago
parent
commit
cc4307d1f3
  1. 15
      framework/yii/i18n/Formatter.php

15
framework/yii/i18n/Formatter.php

@ -131,8 +131,13 @@ class Formatter extends \yii\base\Formatter
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], IntlDateFormatter::NONE);
} else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
if ($formatter !== null) {
$formatter->setPattern($format);
}
}
if ($formatter === null) {
throw new InvalidConfigException(intl_get_error_message());
}
return $formatter->format($value);
}
@ -167,8 +172,13 @@ class Formatter extends \yii\base\Formatter
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, $this->_dateFormats[$format]);
} else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
if ($formatter !== null) {
$formatter->setPattern($format);
}
}
if ($formatter === null) {
throw new InvalidConfigException(intl_get_error_message());
}
return $formatter->format($value);
}
@ -203,8 +213,13 @@ class Formatter extends \yii\base\Formatter
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], $this->_dateFormats[$format]);
} else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
if ($formatter !== null) {
$formatter->setPattern($format);
}
}
if ($formatter === null) {
throw new InvalidConfigException(intl_get_error_message());
}
return $formatter->format($value);
}

Loading…
Cancel
Save