From 7a39be36b6750e07b457e93957e4467d74aad137 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 10 Apr 2005 21:25:42 +0000 Subject: [PATCH] some bugfixes: - date-time: empty date not recogniced - date-timeonly, date-houronly: use only seconds, no timezone converstation between server-time and UTC (default for mktime()) --- etemplate/inc/class.date_widget.inc.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/etemplate/inc/class.date_widget.inc.php b/etemplate/inc/class.date_widget.inc.php index c435a3e704..5232cb2129 100644 --- a/etemplate/inc/class.date_widget.inc.php +++ b/etemplate/inc/class.date_widget.inc.php @@ -66,9 +66,9 @@ { if (!is_object($GLOBALS['phpgw']->jscalendar)) { - $GLOBALS['phpgw']->jscalendar = CreateObject('phpgwapi.jscalendar'); + $GLOBALS['phpgw']->jscalendar =& CreateObject('phpgwapi.jscalendar'); } - $this->jscal = &$GLOBALS['phpgw']->jscalendar; + $this->jscal =& $GLOBALS['phpgw']->jscalendar; } $this->timeformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat']; $this->dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; @@ -127,6 +127,9 @@ } else { + // for the timeformats we use only seconds, no timezone conversation between server-time and UTC + if (substr($type,-4) == 'only') $value -= adodb_date('Z',0); + $value = array( 'Y' => adodb_date('Y',$value), 'm' => adodb_date('m',$value), @@ -325,6 +328,8 @@ { return False; } + $no_date = substr($extension_data['type'],-4) == 'only'; + if ($value['today']) { $set = array('Y','m','d'); @@ -341,8 +346,8 @@ } $value += $this->jscal->input2date($value_in['str'],False,'d','m','Y'); } - if ($value['d'] || isset($value['H']) && $value['H'] !== '' || - isset($value['i']) && $value['i'] !== '') + if ($value['d'] || $no_date && + (isset($value['H']) && $value['H'] !== '' || isset($value['i']) && $value['i'] !== '')) { if ($value['d']) { @@ -380,7 +385,9 @@ $data_format = $extension_data['data_format']; if (empty($data_format)) { - $value = adodb_mktime((int) $value['H'],(int) $value['i'],0,$value['m'],$value['d'],$value['Y']); + // for time or hour format we use just seconds (and no timezone correction between server-time and UTC) + $value = $no_date ? 3600 * (int) $value['H'] + 60 * (int) $value['i'] : + adodb_mktime((int) $value['H'],(int) $value['i'],0,$value['m'],$value['d'],$value['Y']); } else {