Server IP : 103.233.192.212 / Your IP : 3.144.226.114 Web Server : Apache/2 System : Linux sv1.inde.co.th 3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021 x86_64 User : sumpatuan ( 1058) PHP Version : 5.5.38 Disable Function : symlink,shell_exec,exec,proc_close,proc_open,popen,system,dl,putenv,passthru,escapeshellarg,escapeshellcmd,pcntl_exec,proc_get_status,proc_nice,proc_terminate,pclose,ini_alter,virtual,openlog,ini_restore MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/sumpatuan/domains/sumpatuan.go.th/private_html/backup/framework/utils/ |
Upload File : |
<?php /** * CLocalizedFormatter class file. * * @author Carsten Brandt <mail@cebe.cc> * @link http://www.yiiframework.com/ * @copyright 2008-2013 Yii Software LLC * @license http://www.yiiframework.com/license/ */ /** * CLocalizedFormatter provides a set of commonly used data formatting methods based on the current locale settings. * * It provides the same functionality as {@link CFormatter}, but overrides all the settings for * {@link booleanFormat}, {@link datetimeFormat} and {@link numberFormat} with the values for the * current locale. Because of this you are not able to configure these properties for CLocalizedFormatter directly. * Date and time format can be adjsuted by setting {@link dateFormat} and {@link timeFormat}. * * It uses {@link CApplication::locale} by default but you can set a custom locale by using {@link setLocale}-method. * * For a list of recognizable format types, and details on how to call the formatter methods, * see {@link CFormatter} documentation. * * To replace the application component 'format', which is registered by {@link CApplication} by default, you can * put this in your application 'components' config: * <code> * 'format' => array( * 'class' => 'CLocalizedFormatter', * ), * </code> * * @author Carsten Brandt <mail@cebe.cc> * @package system.utils * @since 1.1.14 */ class CLocalizedFormatter extends CFormatter { private $_locale; /** * @var string the width of the date pattern. It can be 'full', 'long', 'medium' and 'short'. Defaults to 'medium'. * @see CDateFormatter::formatDateTime() */ public $dateFormat='medium'; /** * @var string the width of the time pattern. It can be 'full', 'long', 'medium' and 'short'. Defaults to 'medium'. * @see CDateFormatter::formatDateTime() */ public $timeFormat='medium'; /** * Set the locale to use for formatting values. * @param CLocale|string $locale an instance of CLocale or a locale ID */ public function setLocale($locale) { if(is_string($locale)) $locale=CLocale::getInstance($locale); $this->sizeFormat['decimalSeparator']=$locale->getNumberSymbol('decimal'); $this->_locale=$locale; } /** * @return CLocale $locale the locale currently used for formatting values */ public function getLocale() { if($this->_locale === null) { $this->setLocale(Yii::app()->locale); } return $this->_locale; } /** * Formats the value as a boolean. * @param mixed $value the value to be formatted * @return string the formatted result * @see booleanFormat */ public function formatBoolean($value) { return $value ? Yii::t('yii','Yes') : Yii::t('yii','No'); } /** * Formats the value as a date using the {@link locale}s date formatter. * @param mixed $value the value to be formatted * @return string the formatted result * @see dateFormat * @see CLocale::getDateFormatter() */ public function formatDate($value) { return $this->getLocale()->dateFormatter->formatDateTime($this->normalizeDateValue($value), $this->dateFormat, null); } /** * Formats the value as a time using the {@link locale}s date formatter. * @param mixed $value the value to be formatted * @return string the formatted result * @see timeFormat * @see CLocale::getDateFormatter() */ public function formatTime($value) { return $this->getLocale()->dateFormatter->formatDateTime($this->normalizeDateValue($value), null, $this->timeFormat); } /** * Formats the value as a date and time using the {@link locale}s date formatter. * @param mixed $value the value to be formatted * @return string the formatted result * @see dateFormat * @see timeFormat * @see CLocale::getDateFormatter() */ public function formatDatetime($value) { return $this->getLocale()->dateFormatter->formatDateTime($this->normalizeDateValue($value), $this->dateFormat, $this->timeFormat); } /** * Formats the value as a number using the {@link locale}s number formatter. * @param mixed $value the value to be formatted * @return string the formatted result * @see CLocale::getNumberFormatter() */ public function formatNumber($value) { return $this->getLocale()->numberFormatter->formatDecimal($value); } }