From: <ral...@us...> - 2005-10-31 14:36:14
|
Update of /cvsroot/egroupware/calendar/inc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31636 Modified Files: Tag: contacts_and_resources class.bocal.inc.php Log Message: added further date_formats: - 'server' gives timestamp in server-time - arbitrary string to specify any format, eg. the ones for xmlrpc Index: class.bocal.inc.php =================================================================== RCS file: /cvsroot/egroupware/calendar/inc/class.bocal.inc.php,v retrieving revision 1.10.2.35 retrieving revision 1.10.2.36 diff -C2 -d -r1.10.2.35 -r1.10.2.36 *** class.bocal.inc.php 30 Oct 2005 11:31:47 -0000 1.10.2.35 --- class.bocal.inc.php 31 Oct 2005 14:35:56 -0000 1.10.2.36 *************** *** 212,216 **** * (events spanning multiple days are returned each day again (!)) otherwise it returns one array with * the events (default), not honored in a search ==> always returns an array of events ! ! * date_format string date-formats: 'ts'=timestamp (default), 'array'=array, 'string'=iso8601 string for xmlrpc * offset boolean/int false (default) to return all entries or integer offset to return only a limited result * enum_recuring boolean if true or not set (default) or daywise is set, each recurence of a recuring events is returned, --- 212,216 ---- * (events spanning multiple days are returned each day again (!)) otherwise it returns one array with * the events (default), not honored in a search ==> always returns an array of events ! ! * date_format string date-formats: 'ts'=timestamp (default), 'array'=array, or string with format for date * offset boolean/int false (default) to return all entries or integer offset to return only a limited result * enum_recuring boolean if true or not set (default) or daywise is set, each recurence of a recuring events is returned, *************** *** 290,294 **** $users,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$show_rejected); $this->total = $this->so->total; ! $this->db2data($events,$params['date_format']); foreach($events as $id => $event) --- 290,294 ---- $users,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$show_rejected); $this->total = $this->so->total; ! $this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts'); foreach($events as $id => $event) *************** *** 452,456 **** * * @param array &$events array of event-arrays (reference) ! * @param $date_format='ts' date-formats: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc */ function db2data(&$events,$date_format='ts') --- 452,456 ---- * * @param array &$events array of event-arrays (reference) ! * @param $date_format='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format */ function db2data(&$events,$date_format='ts') *************** *** 462,466 **** { if (empty($event[$ts])) continue; ! $events[$id][$ts] = $this->date2usertime($event[$ts],$date_format); } --- 462,466 ---- { if (empty($event[$ts])) continue; ! $events[$id][$ts] = $this->date2usertime($event[$ts],$date_format); } *************** *** 481,486 **** } } - // for compatibility with the old code - $events[$id]['modtime'] = $events[$id]['modified']; } } --- 481,484 ---- *************** *** 490,494 **** * * @param int $date timestamp in server-time ! * @param $date_format='ts' date-formats: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc */ function date2usertime($ts,$date_format='ts') --- 488,492 ---- * * @param int $date timestamp in server-time ! * @param $date_format='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format */ function date2usertime($ts,$date_format='ts') *************** *** 498,508 **** switch ($date_format) { case 'array': return $this->date2array((int) $ts,true); case 'string': ! return $this->date2string($ts,true,true); } ! return $ts + $this->tz_offset_s; } --- 496,512 ---- switch ($date_format) { + case 'ts': + return $ts + $this->tz_offset_s; + + case 'server': + return $ts; + case 'array': return $this->date2array((int) $ts,true); case 'string': ! return $this->date2string($ts,true); } ! return $this->date2string($ts,true,$date_format); } *************** *** 513,517 **** * @param mixed $date=null date to specify a single event of a series * @param boolean $ignore_acl should we ignore the acl, default False for a single id, true for multiple id's ! * @param string $date_format='ts' date-formats: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc * @return boolean/array event or array of id => event pairs or False if the acl-check went wrong */ --- 517,521 ---- * @param mixed $date=null date to specify a single event of a series * @param boolean $ignore_acl should we ignore the acl, default False for a single id, true for multiple id's ! * @param string $date_format='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in servertime, 'array'=array, or string with date-format * @return boolean/array event or array of id => event pairs or False if the acl-check went wrong */ *************** *** 863,867 **** * * @param $date mixed date to convert, should be one of the following types ! * string (!) in form YYYYMMDD or iso8601 YYYY-MM-DDThh:mm:ss * int already a timestamp * array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year' --- 867,871 ---- * * @param $date mixed date to convert, should be one of the following types ! * string (!) in form YYYYMMDD or iso8601 YYYY-MM-DDThh:mm:ss or YYYYMMDDThhmmss * int already a timestamp * array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year' *************** *** 881,905 **** break; } ! if ($date[10] == 'T') ! { ! $date = array( ! 'year' => (int) substr($date,0,4), ! 'month' => (int) substr($date,5,2), ! 'day' => (int) substr($date,8,2), ! 'hour' => (int) substr($date,11,2), ! 'minute' => (int) substr($date,14,2), ! 'second' => (int) substr($date,17,2), ! ); ! } ! else ! { ! $date = array( ! 'year' => (int) substr($date,0,4), ! 'month' => (int) substr($date,4,2), ! 'day' => (int) substr($date,6,2), ! ); ! } // fall-through ! case 'array': // day or mday, month and year keys if (isset($date['raw']) && $date['raw']) // we already have a timestamp { --- 885,902 ---- break; } ! // ToDo: evaluate evtl. added timezone ! ! // removing all non-nummerical chars, gives YYYYMMDDhhmmss, independent of the iso8601 format ! $date = str_replace(array('-',':','T','Z',' '),'',$date); ! $date = array( ! 'year' => (int) substr($date,0,4), ! 'month' => (int) substr($date,4,2), ! 'day' => (int) substr($date,6,2), ! 'hour' => (int) substr($date,8,2), ! 'minute' => (int) substr($date,10,2), ! 'second' => (int) substr($date,12,2), ! ); // fall-through ! case 'array': // day, month and year keys if (isset($date['raw']) && $date['raw']) // we already have a timestamp { *************** *** 907,918 **** break; } - foreach(array('mday'=>'day','min'=>'minute','sec'=>'second') as $old => $new) - { - if (!isset($date[$new]) && isset($date[$old])) // support the old format too - { - $date[$new] = $date[$old]; - unset($date[$old]); - } - } if (!isset($date['year']) && isset($date['full'])) { --- 904,907 ---- *************** *** 967,974 **** } $arr['raw'] = $date; - // for compatibility with the old code, can be removed once bocalendar and uicalendar are gone - $arr['mday'] =& $arr['day']; - $arr['min'] =& $arr['minute']; - $arr['sec'] =& $arr['second']; } if ($this->debug && ($this->debug > 3 || $this->debug == 'date2array')) --- 956,959 ---- *************** *** 982,995 **** * Converts a date as timestamp or array to a date-string and optionaly converts server- to user-time * ! * @param $date mixed integer timestamp or array with ('year','month',..,'second') to convert ! * @param $server2user_time boolean conversation between user- and server-time default False == Off ! * @param $iso8601 boolean return a iso8601 date (YYYY-MM-DDThh:ii:ss), default False == Off ! * @return YYYYMMDD or iso8601 date as string */ ! function date2string($date,$server2user=False,$iso8601=False) { $date_in = $date; ! if (is_array($date) && isset($date['full']) && !$server2user && !$iso8601) { $date = $date['full']; --- 967,982 ---- * Converts a date as timestamp or array to a date-string and optionaly converts server- to user-time * ! * @param mixed $date integer timestamp or array with ('year','month',..,'second') to convert ! * @param boolean $server2user_time conversation between user- and server-time default False == Off, not used if $format ends with \Z ! * @param string $format='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100) ! * @return string date formatted according to $format */ ! function date2string($date,$server2user=False,$format='Ymd') { $date_in = $date; ! if (!$format) $format = 'Ymd'; ! ! if (is_array($date) && isset($date['full']) && !$server2user && $format == 'Ymd') { $date = $date['full']; *************** *** 998,1011 **** { $date = $this->date2ts($date,False); ! ! if ($server2user) { $date += $this->tz_offset_s; } ! $date = adodb_date(($iso8601 ? 'Y-m-d\TH:i:s' : 'Ymd'),$date); } if ($this->debug && ($this->debug > 3 || $this->debug == 'date2string')) { ! $this->debug_message('bocal::date2string(%1,server2user=%2,iso8601=%3)=%4)',False,$date_in,$server2user,$iso8601,$date); } return $date; --- 985,1008 ---- { $date = $this->date2ts($date,False); ! ! // if timezone is requested, we dont need to convert to user-time ! if (($tz_used = substr($format,-1)) == 'O' || $tz_used == 'Z') $server2user = false; ! ! if ($server2user && substr($format,-1) ) { $date += $this->tz_offset_s; } ! if (substr($format,-2) == '\\Z') // GMT aka. Zulu time ! { ! $date = adodb_gmdate($format,$date); ! } ! else ! { ! $date = adodb_date($format,$date); ! } } if ($this->debug && ($this->debug > 3 || $this->debug == 'date2string')) { ! $this->debug_message('bocal::date2string(%1,server2user=%2,format=%3)=%4)',False,$date_in,$server2user,$format,$date); } return $date; |