From fdf4dcb9b9fecf56eb6588226956797444c465f8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 24 Dec 2009 02:00:51 +0000 Subject: [PATCH] fixed not working $$time$$ and $$date$$ placeholders, by using egw_time::to() and deprecating format_datetime() --- etemplate/inc/class.bo_merge.inc.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 37d6402673..b064a51fed 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -232,17 +232,16 @@ abstract class bo_merge /** * Format a datetime * - * @param int|string $time unix timestamp or Y-m-d H:i:s string (in user time!) + * @param int|string|DateTime $time unix timestamp or Y-m-d H:i:s string (in user time!) * @param string $format=null format string, default $this->datetime_format + * @deprecated use egw_time::to($time='now',$format='') * @return string */ protected function format_datetime($time,$format=null) { if (is_null($format)) $format = $this->datetime_format; - if (empty($time)) return ''; - - return date($this->datetime_format,is_numeric($time) ? $time : strtotime($time)); + return egw_time::to($time,$format); } /** @@ -323,10 +322,9 @@ abstract class bo_merge { $replacements += $this->contact_replacements($user,'user'); } - $now = time()+$this->contacts->tz_offset_s; - $replacements['$$date$$'] = $this->format_datetime($now,$GLOBALS['egw_info']['user']['preferences']['common']['dateformat']); - $replacements['$$datetime$$'] = $this->format_datetime($now); - $replacements['$$time$$'] = $this->format_datetime($now,$GLOBALS['egw_info']['user']['preferences']['common']['timeformat']==12?'h:i a':'H:i'); + $replacements['$$date$$'] = egw_time::to('now',true); + $replacements['$$datetime$$'] = egw_time::to('now'); + $replacements['$$time$$'] = egw_time::to('now',false); // does our extending class registered table-plugins AND document contains table tags if ($this->table_plugins && preg_match_all('/\\$\\$table\\/([A-Za-z0-9_]+)\\$\\$(.*?)\\$\\$endtable\\$\\$/s',$content,$matches,PREG_SET_ORDER))