Copyright 2009-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21. Code dealing with searching for a timezone identifier from an AS timezone blob inspired by code in the Tine20 Project (http://tine20.org).
Author: Michael J Rubinsky (mrubinsk@horde.org)
Ejemplo n.º 1
0
 /**
  * Test guessing a timezone identifier from an ActiveSync timezone
  * structure.
  */
 public function testGuessTimezoneFromOffsets()
 {
     $timezones = new Horde_Mapi_Timezone();
     // Test general functionality, with expected timezone.
     foreach ($this->_packed as $tz => $blob) {
         $guessed = $timezones->getTimezone($blob, $tz);
         $this->assertEquals($tz, $guessed);
     }
     // Test without a known timezone
     $guessed = $timezones->getTimezone($this->_packed['America/New_York']);
     $this->assertEquals('America/New_York', $guessed);
     $guessed = $timezones->getTimezone($this->_packed['Europe/Berlin']);
     $this->assertEquals('Europe/Berlin', $guessed);
 }
Ejemplo n.º 2
0
 /**
  * Get the event's timezone
  *
  * @return string  The timezone identifier
  */
 public function getTimezone()
 {
     $parser = new Horde_Mapi_Timezone();
     return $parser->getTimezone($this->timezone, date_default_timezone_get());
 }
Ejemplo n.º 3
0
 /**
  * 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();
 }