toDateTime() public method

Returns a DateTime object representing this object.
public toDateTime ( ) : DateTime
return DateTime
コード例 #1
0
ファイル: Timezone.php プロジェクト: raz0rsdge/horde
 /**
  * Create a offset hash suitable for use in ActiveSync transactions
  *
  * @param Horde_Date $date  A date object representing the date to base the
  *                          the tz data on.
  *
  * @return array  An offset hash.
  */
 public static function getOffsetsFromDate(Horde_Date $date)
 {
     $offsets = array('bias' => 0, 'stdname' => '', 'stdyear' => 0, 'stdmonth' => 0, 'stdday' => 0, 'stdweek' => 0, 'stdhour' => 0, 'stdminute' => 0, 'stdsecond' => 0, 'stdmillis' => 0, 'stdbias' => 0, 'dstname' => '', 'dstyear' => 0, 'dstmonth' => 0, 'dstday' => 0, 'dstweek' => 0, 'dsthour' => 0, 'dstminute' => 0, 'dstsecond' => 0, 'dstmillis' => 0, 'dstbias' => 0);
     $timezone = $date->toDateTime()->getTimezone();
     // If transition parsing failed, we won't have a multi-element array.
     $transitions = self::_getTransitions($timezone, $date);
     if (!empty($transitions)) {
         list($std, $dst) = self::_getTransitions($timezone, $date);
     }
     if (!empty($std)) {
         $offsets['bias'] = $std['offset'] / 60 * -1;
         if ($dst) {
             $offsets = self::_generateOffsetsForTransition($offsets, $std, 'std');
             $offsets = self::_generateOffsetsForTransition($offsets, $dst, 'dst');
             $offsets['stdhour'] += $dst['offset'] / 3600;
             $offsets['dsthour'] += $std['offset'] / 3600;
             $offsets['dstbias'] = ($dst['offset'] - $std['offset']) / 60 * -1;
         }
     }
     return $offsets;
 }