Example #1
0
 public function FormatDate($params, &$smarty)
 {
     if (isset($params['format'])) {
         return $params['date']->Format($params['format']);
     }
     $key = 'general_date';
     if (isset($params['key'])) {
         $key = $params['key'];
     }
     return $params['date']->Format($this->Resources->GetDateFormat($key));
 }
Example #2
0
 public function FormatDate($params, &$smarty)
 {
     if (!isset($params['date']) || empty($params['date'])) {
         return '';
     }
     $date = is_string($params['date']) ? Date::Parse($params['date']) : $params['date'];
     /** @var $date Date */
     $date = isset($params['timezone']) ? $date->ToTimezone($params['timezone']) : $date;
     if (isset($params['format'])) {
         return $date->Format($params['format']);
     }
     $key = 'general_date';
     if (isset($params['key'])) {
         $key = $params['key'];
     }
     $format = $this->Resources->GetDateFormat($key);
     $formatted = $date->Format($format);
     if (strpos($format, 'l') !== false) {
         // correct english day name to translated day name
         $english_days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
         $days = $this->Resources->GetDays('full');
         $formatted = str_replace($english_days[$date->Weekday()], $days[$date->Weekday()], $formatted);
     }
     return $formatted;
 }