public function testDatenArrayConverstions() { $date = new Tinebase_DateTime('1979-06-05 11:22:33'); $dateArray = array('day' => 5, 'month' => 6, 'year' => 1979, 'hour' => 11, 'minute' => 22, 'second' => 33); $this->assertTrue($date->equals(Calendar_Model_Rrule::array2date($dateArray)), 'array2date failed'); $this->assertEquals($dateArray, Calendar_Model_Rrule::date2array($date), 'date2array failed'); }
/** * converts egw rrule into tine/iCal rrule * * @param array $_egwEventData * @return Calendar_Model_Rrule */ protected function _convertRrule($_egwEventData) { $egwRrule = $_egwEventData['rrule']; $rrule = new Calendar_Model_Rrule(array()); if (!(isset($this->_rruleFreqMap[$egwRrule['recur_type']]) || array_key_exists($egwRrule['recur_type'], $this->_rruleFreqMap))) { throw new Exception('unsupported rrule freq'); } $rrule->freq = $this->_rruleFreqMap[$egwRrule['recur_type']]; $rrule->interval = $egwRrule['recur_interval']; $rrule->until = $this->convertDate($egwRrule['recur_enddate']); // weekly/monthly by wday if ($egwRrule['recur_type'] == 2 || $egwRrule['recur_type'] == 4) { $wdays = array(); foreach ($this->_rruleWdayMap as $egwBit => $iCalString) { if ($egwRrule['recur_data'] & $egwBit) { $wdays[] = $iCalString; } } $rrule->byday = implode(',', $wdays); } // monthly byday/yearly bymonthday if ($egwRrule['recur_type'] == 3 || $egwRrule['recur_type'] == 5) { $dtstart = $this->convertDate($_egwEventData['cal_start']); $dateArray = Calendar_Model_Rrule::date2array($dtstart); $rrule->bymonthday = $dateArray['day']; if ($egwRrule['recur_type'] == 5) { $rrule->bymonth = $dateArray['month']; } } return $rrule; }