/** * Renders the localized version of the date-time value. * If the culture is not specified, the default application * culture will be used. * This method overrides parent's implementation. */ protected function getFormattedDate() { $value = $this->getValue(); $defaultText = $this->getDefaultText(); if (empty($value) && !empty($defaultText)) { return $this->getDefaultText(); } $app = $this->getApplication()->getGlobalization(); //initialized the default class wide formatter if (self::$formatter === null) { self::$formatter = new DateFormat($app->getCulture()); } $culture = $this->getCulture(); //return the specific cultural formatted date time if (strlen($culture) && $app->getCulture() !== $culture) { $formatter = new DateFormat($culture); return $formatter->format($value, $this->getPattern(), $this->getCharset()); } //return the application wide culture formatted date time. $result = self::$formatter->format($value, $this->getPattern(), $this->getCharset()); return $result; }
/** * Renders the localized version of the date-time value. * If the culture is not specified, the default application * culture will be used. * This method overrides parent's implementation. */ protected function renderBody() { $app = $this->Application->getGlobalization(); //initialized the default class wide formatter if (is_null(self::$formatter)) { self::$formatter = new DateFormat($app->Culture); } $culture = $this->getCulture(); $value = $this->getValue(); //return the specific cultural formatted date time if (strlen($culture) && $app->Culture !== $culture) { $formatter = new DateFormat($culture); return $formatter->format($value, $this->getPattern()); } $charset = $this->getCharset(); if (empty($charset)) { $charset = 'UTF-8'; } //return the application wide culture formatted date time. return self::$formatter->format($value, $this->getPattern(), $charset); }