getOffsetsFromDate() public static method

Create a offset hash suitable for use in ActiveSync transactions
public static getOffsetsFromDate ( Horde_Date $date ) : array
$date Horde_Date A date object representing the date to base the the tz data on.
return array An offset hash.
Example #1
0
 /**
  * Test creating a Offset hash for a given timezone.
  */
 public function testGetOffsetsFromDate()
 {
     // The actual time doesn't matter, we really only need a year and a
     // timezone that we are interested in.
     foreach ($this->_offsets as $tz => $expected) {
         $date = new Horde_Date('2011-07-01', $tz);
         $offsets = Horde_Mapi_Timezone::getOffsetsFromDate($date);
         foreach ($offsets as $key => $value) {
             $this->assertEquals($expected[$key], $value);
         }
     }
 }
Example #2
0
 /**
  * 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;
 }
Example #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();
 }