Build an MAPI TZ blob given a TZ Offset hash.
public static getSyncTZFromOffsets ( array $offsets ) : string | ||
$offsets | array | A TZ offset hash |
리턴 | string | A base64_encoded MAPI Timezone structure suitable for transmitting via wbxml. |
/** * Test generating an ActiveSync TZ structure given a TZ Offset hash */ public function testGetSyncTZFromOffsets() { foreach ($this->_offsets as $tz => $offsets) { $blob = Horde_Mapi_Timezone::getSyncTZFromOffsets($offsets); $this->assertEquals($this->_packed[$tz], $blob); } }
/** * Set the timezone * * @param mixed $date Either a Horde_Date or timezone descriptor such as * America/New_York etc... * * @throws InvalidArgumentException */ public function setTimezone($date) { if (!$date instanceof Horde_Date) { if (!is_string($date)) { throw new InvalidArgumentException('$date must be an instance of Horde_Date or a valid timezone descriptor'); } $date = new Horde_Date(time(), $date); } $offsets = Horde_Mapi_Timezone::getOffsetsFromDate($date); $tz = Horde_Mapi_Timezone::getSyncTZFromOffsets($offsets); $this->_properties['timezone'] = $tz; }
/** * Create a meeting request from a vEvent. * * @param Horde_Icalendar_Vevent $vCal The vEvent. * * @throws Horde_ActiveSync_Exception */ public function fromvEvent($vCal) { try { $method = $vCal->getAttribute('METHOD'); } catch (Horde_Icalendar_Exception $e) { throw new Horde_ActiveSync_Exception('Unable to parse vEvent'); } foreach ($vCal->getComponents() as $component) { switch ($component->getType()) { case 'vEvent': $this->_vEvent = $component; $this->_parsevEvent($component, $method); break; case 'vTimeZone': // Not sure what to do with Timezone yet/how to get it into // a TZ structure etc... For now, defaults to default timezone (as the // specs say it should for iCal without tz specified). // Not sure what to do with Timezone yet/how to get it into // a TZ structure etc... For now, defaults to default timezone (as the // specs say it should for iCal without tz specified). default: break; } } // Ensure we actually have a vEvent to parse. if (empty($this->_vEvent)) { return; } $tz = new Horde_Mapi_Timezone(); try { $this->timezone = $tz->getSyncTZFromOffsets($tz->getOffsetsFromDate(new Horde_Date($this->_vEvent->getAttribute('DTSTART')))); } catch (Horde_Icalendar_Exception $e) { } $this->alldayevent = (int) $this->_isAllDay(); }