Beispiel #1
0
 function &getClientTZ()
 {
     // if SITE_TIME_ZONE is present, use it, otherwise, best guess as to server's local time zone
     if (defined('SITE_TIME_ZONE') && Date_TimeZone::isValidID(SITE_TIME_ZONE)) {
         $client_tz = new Date_TimeZone(SITE_TIME_ZONE);
     } else {
         $client_tz =& Date_TimeZone::getDefault();
     }
     return $client_tz;
 }
Beispiel #2
0
 function NDate($date = null, $now = null)
 {
     $n = func_num_args();
     $p = $n == 3;
     $args = func_get_args();
     $this->tz = Date_TimeZone::getDefault();
     if ($n == 0) {
         return parent::Date();
     }
     $n--;
     $date = $args[$n];
     if (is_array($date)) {
         $this->setDate($date);
     } elseif (is_int($date) || is_string($date) && (string) (int) $date == (string) $date && $date < 9876543210 && $date > 01234567) {
         // Looks like a UNIX timestamp
         parent::Date($date);
     } elseif (is_string($date)) {
         $this->setDate(strtotime($date));
     } else {
         parent::Date($date);
     }
     while ($n > 0) {
         $n--;
         $now = $this->getDate(DATE_FORMAT_UNIXTIME);
         $date = $args[$n];
         switch ($date) {
             case "1st":
             case "first":
                 $this->setDay(1);
                 break;
             case "last":
                 $this->setDay($this->getDaysInMonth());
                 break;
             default:
                 $this->setDate(strtotime($date, $now));
         }
     }
 }
Beispiel #3
0
 /**
  * Sets the system default time zone to the time zone in $id
  *
  * Sets the system default time zone to the time zone in $id
  *
  * @access public
  * @param string $id the time zone id to use
  */
 function setDefault($id)
 {
     global $default;
     if (Date_TimeZone::isValidID($id)) {
         $default = $id;
     }
 }
Beispiel #4
0
 /**
  * Returns an array of available timezones.
  *
  * @static
  * @param boolean $addBlank If set to true an empty entry will be added
  *                          to the beginning of the array.
  * @return array An array containing all the available timezones.
  */
 function availableTimezones($addBlank = false)
 {
     global $_DATE_TIMEZONE_DATA;
     $_aTimezoneBcData = array('Brazil/Acre', 'Brazil/DeNoronha', 'Brazil/East', 'Brazil/West', 'Canada/Atlantic', 'Canada/Central', 'Canada/East-Saskatchewan', 'Canada/Eastern', 'Canada/Mountain', 'Canada/Newfoundland', 'Canada/Pacific', 'Canada/Saskatchewan', 'Canada/Yukon', 'CET', 'Chile/Continental', 'Chile/EasterIsland', 'CST6CDT', 'Cuba', 'EET', 'Egypt', 'Eire', 'EST', 'EST5EDT', 'Etc/GMT', 'Etc/GMT+0', 'Etc/GMT+1', 'Etc/GMT+10', 'Etc/GMT+11', 'Etc/GMT+12', 'Etc/GMT+2', 'Etc/GMT+3', 'Etc/GMT+4', 'Etc/GMT+5', 'Etc/GMT+6', 'Etc/GMT+7', 'Etc/GMT+8', 'Etc/GMT+9', 'Etc/GMT-0', 'Etc/GMT-1', 'Etc/GMT-10', 'Etc/GMT-11', 'Etc/GMT-12', 'Etc/GMT-13', 'Etc/GMT-14', 'Etc/GMT-2', 'Etc/GMT-3', 'Etc/GMT-4', 'Etc/GMT-5', 'Etc/GMT-6', 'Etc/GMT-7', 'Etc/GMT-8', 'Etc/GMT-9', 'Etc/GMT0', 'Etc/Greenwich', 'Etc/UCT', 'Etc/Universal', 'Etc/UTC', 'Etc/Zulu', 'Factory GB', 'GB-Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'Greenwich', 'Hongkong', 'HST', 'Iceland', 'Iran', 'Israel', 'Jamaica', 'Japan', 'Kwajalein', 'Libya', 'MET', 'Mexico/BajaNorte', 'Mexico/BajaSur', 'Mexico/General', 'MST', 'MST7MDT', 'Navajo', 'NZ', 'NZ-CHAT', 'Poland', 'Portugal', 'PRC', 'PST8PDT', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT', 'Universal', 'US/Alaska', 'US/Aleutian', 'US/Arizona', 'US/Central', 'US/East-Indiana', 'US/Eastern', 'US/Hawaii', 'US/Indiana-Starke', 'US/Michigan', 'US/Mountain', 'US/Pacific', 'US/Pacific-New', 'US/Samoa', 'UTC', 'W-SU', 'WET', 'Zulu');
     // Load translations
     require_once MAX_PATH . '/lib/max/language/Loader.php';
     Language_Loader::load('timezone');
     // Load global array of timezones
     require_once MAX_PATH . '/lib/pear/Date/TimeZone.php';
     $aTimezoneKey = Date_TimeZone::getAvailableIDs();
     if (!defined('MAX_PATH')) {
         $tz = OX_Admin_Timezones::getTimezone();
     } else {
         $tz = $GLOBALS['_MAX']['PREF']['timezone'];
         if (is_null($tz)) {
             $tz = OX_Admin_Timezones::getTimezone();
         }
     }
     foreach ($aTimezoneKey as $key) {
         if (in_array($tz, $_aTimezoneBcData) && $key == $tz || !in_array($key, $_aTimezoneBcData)) {
             // Calculate the timezone offset
             $offset = OX_Admin_Timezones::_convertOffset($_DATE_TIMEZONE_DATA[$key]['offset']);
             // Build the arrays used for sorting time zones
             $origOffset = $_DATE_TIMEZONE_DATA[$key]['offset'];
             $key = !empty($GLOBALS['strTimezoneList'][$key]) ? $GLOBALS['strTimezoneList'][$key] : $key;
             if ($origOffset >= 0) {
                 $aTimezone[$offset][$key] = "(GMT+{$offset}) {$key}";
             } else {
                 $aNegTimezone[$key] = "(GMT-{$offset}) {$key}";
             }
         }
     }
     // Sort timezones with positive offsets descending, and negative
     // offests ascending.
     // Add initial empty key/value pair
     if ($addBlank) {
         $aResult[] = '';
     }
     // Sort time zones
     asort($aNegTimezone);
     // Reverse array element order while preserving alphabetical order
     $hasRun = false;
     foreach ($aTimezone as $offset => $aValue) {
         if ($hasRun == false) {
             $aRevTimezone[] = $aValue;
             $hasRun = true;
         } else {
             array_unshift($aRevTimezone, $aValue);
         }
     }
     // Build the result array
     foreach ($aRevTimezone as $aValue) {
         foreach ($aValue as $k => $v) {
             $aResult[$k] = $v;
         }
     }
     foreach ($aNegTimezone as $key => $value) {
         $aResult[$key] = $value;
     }
     return $aResult;
 }
 function get_display_timezone($_user = false)
 {
     global $prefs, $user;
     if ($_user === false || $_user == $user) {
         // If the requested timezone is the current user timezone
         $tz = $prefs['display_timezone'];
     } elseif ($_user) {
         // ... else, get the user timezone preferences from DB
         $tz = $this->get_user_preference($_user, 'display_timezone');
         if (!Date_TimeZone::isValidID($tz)) {
             $tz = $prefs['server_timezone'];
         }
     }
     return $tz;
 }
 /**
  * Get the user's preferred timezone
  *
  * @return   string  name of the timezone
  * @static
  *
  */
 public static function getUserTimeZone()
 {
     global $_CONF, $_USER;
     // handle like the theme cookie, i.e. use if user is not logged in
     if (isset($_COOKIE[$_CONF['cookie_tzid']]) && empty($_USER['tzid'])) {
         $_USER['tzid'] = $_COOKIE[$_CONF['cookie_tzid']];
     }
     if (!empty($_USER['tzid'])) {
         $timezone = $_USER['tzid'];
     } elseif (!empty($_CONF['timezone'])) {
         $timezone = $_CONF['timezone'];
     } elseif (function_exists('date_default_timezone_get')) {
         $timezone = @date_default_timezone_get();
     } else {
         require_once 'Date/TimeZone.php';
         $tz_obj = Date_TimeZone::getDefault();
         $timezone = $tz_obj->id;
     }
     return $timezone;
 }
 /**
  * Provide a list of available timezones
  *
  * @return   array   array of (timezone-short-name, timezone-long-name) pairs
  */
 public static function listAvailableTimeZones()
 {
     $timezones = array();
     // use only timezones that contain one of these
     $useOnly = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'UTC');
     // check if we can use the DateTimeZone class
     $useDateTimeZone = false;
     if (class_exists('DateTimeZone') && class_exists('ReflectionClass')) {
         $rc = new ReflectionClass('DateTimeZone');
         if ($rc->hasMethod('listAbbreviations')) {
             $useDateTimeZone = true;
         }
     }
     if ($useDateTimeZone) {
         $T = DateTimeZone::listAbbreviations();
         foreach ($T as $tzId => $entries) {
             $shortName = strtoupper($tzId);
             foreach ($entries as $data) {
                 $tzCheck = explode('/', $data['timezone_id']);
                 if (!in_array($tzCheck[0], $useOnly)) {
                     continue;
                 }
                 $hours = $data['offset'] / 3600;
                 $hours = (int) ($hours * 100) / 100;
                 if ($hours > 0) {
                     $hours = "+{$hours}";
                 }
                 $tzCode = str_replace('_', ' ', $data['timezone_id']);
                 $tzCode = htmlspecialchars($tzCode);
                 $formattedTimezone = "{$hours}, {$shortName} ({$tzCode})";
                 $timezones[$data['timezone_id']] = $formattedTimezone;
             }
         }
     } else {
         // DateTimeZone not available - use PEAR Date class
         // Load Date_TimeZone class
         Date_TimeZone::getDefault();
         $T = $GLOBALS['_DATE_TIMEZONE_DATA'];
         foreach ($T as $tzId => $tDetails) {
             $tzCheck = explode('/', $tzId);
             if (!in_array($tzCheck[0], $useOnly)) {
                 continue;
             }
             if (!empty($tzCheck[1]) && strpos($tzCheck[1], 'Riyadh') === 0) {
                 // these time zones are based on solar time and not widely
                 // supported - skip
                 continue;
             }
             $tzCode = str_replace('_', ' ', $tzId);
             $tzCode = htmlspecialchars($tzCode);
             $hours = $tDetails['offset'] / (3600 * 1000);
             $hours = (int) ($hours * 100) / 100;
             if ($hours > 0) {
                 $hours = "+{$hours}";
             }
             $formattedTimezone = "{$hours}, {$tDetails['shortname']} ({$tzCode})";
             $timezones[$tzId] = $formattedTimezone;
         }
     }
     uasort($timezones, array('TimeZoneConfig', '_sort_by_timezone'));
     return $timezones;
 }
Beispiel #8
0
 /**
  * Converts this date to a new time zone, given a valid time zone ID
  *
  * Converts this date to a new time zone, given a valid time zone ID
  * WARNING: This may not work correctly if your system does not allow
  * putenv() or if localtime() does not work in your environment.  See
  * Date::TimeZone::inDaylightTime() for more information.
  *
  * @access public
  * @param string id a time zone id
  */
 function convertTZbyID($id)
 {
     if (Date_TimeZone::isValidID($id)) {
         $tz = new Date_TimeZone($id);
     } else {
         $tz = Date_TimeZone::getDefault();
     }
     $this->convertTZ($tz);
 }
Beispiel #9
0
 /**
  * Converts this date to a new time zone, given a valid time zone ID
  *
  * Previously this might not have worked correctly if your system did
  * not allow putenv() or if localtime() does not work in your
  * environment, but this implementation is no longer used.
  *
  * @param string $ps_id a valid time zone id, e.g. 'Europe/London'
  *
  * @return   void
  * @access   public
  * @see      Date::setTZByID(), Date_TimeZone::isValidID(),
  *            Date_TimeZone::Date_TimeZone()
  */
 function convertTZByID($ps_id)
 {
     if (!Date_TimeZone::isValidID($ps_id)) {
         return PEAR::raiseError("Invalid time zone ID '{$ps_id}'", DATE_ERROR_INVALIDTIMEZONE);
     }
     $res = $this->convertTZ(new Date_TimeZone($ps_id));
     if (PEAR::isError($res)) {
         return $res;
     }
 }
Beispiel #10
0
 function calc_timezone($newdate)
 {
     global $pref;
     if (!$pref['datetime'] || !$this->TimeZone) {
         $newdate = preg_replace('/UT$/', 'UTC', $newdate);
         $newdate = date("D, j M Y G:i O", strtotime($newdate));
         return $newdate;
     }
     require_once 'Date.php';
     // convert to ISO 8601 format
     if (preg_match('/(\\d+) ([a-z]+) (\\d\\d\\d?\\d?) (\\d\\d:\\d\\d:\\d\\d) ((\\+|-)\\d\\d\\d\\d|[a-z]+)/i', $newdate, $m)) {
         if (strlen($m[1]) == 1) {
             $m[1] = "0{$m['1']}";
         }
         // If a 2 digit date is given then we need to make an assumption
         // about the actual year. If year >= 80 we can safely assume that
         // it's a 20th Century date e.g. 89 becomes 1989. Otherwise lets make it
         // a 21st Century date, e.g. 08 becomes 2008
         if (strlen($m[3]) == 2) {
             $m[3] = $m[3] >= 80 ? "19{$m['3']}" : "20{$m['3']}";
         }
         // format month name with uppercase firt char e.g Sep
         $m[2] = ucfirst(strtolower($m[2]));
         // Convert Timezone ID to GMT offset
         if (!is_numeric($m[5])) {
             // convert UT > UTC
             if ($m[5] == 'UT') {
                 $m[5] = 'UTC';
             }
             $dt = new Date_TimeZone($m[5]);
             $m[5] = $dt->getRawOffset();
             if ($m[5] == 0) {
                 $m[5] = 'Z';
             } else {
                 $m[5] = $m[5] / 36000;
                 settype($m[5], 'string');
                 $m[5] = preg_replace('/(-|\\+)/', '${1}0', $m[5]);
             }
         }
         $newdate = "{$m['3']}{$this->months[$m[2]]}{$m['1']}T{$m['4']}{$m['5']}";
         // Do timezone conversion
         $date = new Date($newdate);
         $date->convertTZbyID($this->TimeZone);
         $newdate = $date->getDate();
         $newdate = date("D, j M Y G:i O", strtotime($newdate));
     } elseif (preg_match('/(\\d+) ([a-z]+) (\\d\\d\\d\\d) (\\d\\d:\\d\\d:\\d\\d) (\\w+)/i', $newdate, $m)) {
         if (strlen($m[1]) == 1) {
             $m[1] = "0{$m['1']}";
         }
         // If a 2 digit date is given then we need to make an assumption
         // about the actual year. If year >= 80 we can safely assume that
         // it's a 20th Century date e.g. 89 becomes 1989. Otherwise lets make it
         // a 21st Century date, e.g. 08 becomes 2008
         if (strlen($m[3]) == 2) {
             $m[3] = $m[3] >= 80 ? "19{$m['3']}" : "20{$m['3']}";
         }
         // format month name with uppercase firt char e.g Sep
         $m[2] = ucfirst(strtolower($m[2]));
         $newdate = "{$m['3']}{$this->months[$m[2]]}{$m['1']}";
         // Convert date from timezone ID, rather than +0900 or -1100 format, format in GMT, MST, etc
         $date = new Date($newdate);
         $date->setTZByID($m[5]);
         $newdate = $date->getDate();
         $newdate = date("D, j M Y G:i O", strtotime($newdate));
     } else {
         $newdate = date("D, j M Y G:i O", strtotime($newdate));
     }
     return $newdate;
 }
 /**
  * Return a string expression of the server time zone
  *
  * @return           mixed  '(+|-)\d\d:\d\d' or false
  * @see              PEAR Date/TimeZone.php
  */
 private function getTimezoneStr()
 {
     global $_CONF;
     static $retval = null;
     if ($retval === null) {
         if (isset($_CONF['timezone'])) {
             $timezone = $_CONF['timezone'];
             // Load Date_TimeZone class
             Date_TimeZone::getDefault();
             if (array_key_exists($timezone, $GLOBALS['_DATE_TIMEZONE_DATA'])) {
                 $offset = $GLOBALS['_DATE_TIMEZONE_DATA'][$timezone]['offset'];
                 if ($offset >= 0) {
                     $retval = '+';
                 } else {
                     $retval = '-';
                     $offset = -$offset;
                 }
                 $hour = floor($offset / 3600000);
                 $min = ($offset - 3600000 * $hour) % 60000;
                 $retval .= sprintf('%02d:%02d', $hour, $min);
             } else {
                 COM_errorLog(__METHOD__ . ': $_CONF[\'timezone\'] is wrong: ' . $_CONF['timezone']);
                 $retval = false;
             }
         } else {
             $retval = false;
         }
     }
     return $retval;
 }
 public function getTaskNotify(CTask $task, $user, $projname)
 {
     $body = $this->_AppUI->_('Project', UI_OUTPUT_RAW) . ":\t" . $projname . "\n";
     $body .= $this->_AppUI->_('Task', UI_OUTPUT_RAW) . ":\t\t" . $task->task_name . "\n";
     $body .= $this->_AppUI->_('Priority', UI_OUTPUT_RAW) . ":\t" . $task->task_priority . "\n";
     $body .= $this->_AppUI->_('Progress', UI_OUTPUT_RAW) . ":\t" . $task->task_percent_complete . "%\n";
     $tmp_tz = $this->_AppUI->getPref('TIMEZONE');
     $user_prefs = $this->_AppUI->loadPrefs($user['assignee_id'], true);
     $this->_AppUI->user_prefs['TIMEZONE'] = $user_prefs['TIMEZONE'];
     $start_date = new w2p_Utilities_Date($this->_AppUI->formatTZAwareTime($task->task_start_date, '%Y-%m-%d %T'));
     $fmt_start_date = $start_date->format($user_prefs['DISPLAYFORMAT']);
     $end_date = new w2p_Utilities_Date($this->_AppUI->formatTZAwareTime($task->task_end_date, '%Y-%m-%d %T'));
     $fmt_end_date = $end_date->format($user_prefs['DISPLAYFORMAT']);
     $timezoneObj = new Date_TimeZone($user_prefs['TIMEZONE']);
     $tzString = $timezoneObj->getShortName();
     $this->_AppUI->user_prefs['TIMEZONE'] = $tmp_tz;
     // Format dates using preferences but add T as Timezone abbreviation
     $body .= $this->_AppUI->_('Start Date') . ":\t" . $fmt_start_date . " {$tzString}\n";
     $body .= $this->_AppUI->_('Finish Date') . ":\t" . $fmt_end_date . " {$tzString}\n";
     $body .= $this->_AppUI->_('URL', UI_OUTPUT_RAW) . ":\t\t" . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $task->task_id . "\n\n";
     $body .= $this->_AppUI->_('Description', UI_OUTPUT_RAW) . ': ' . "\n" . $task->task_description;
     if ($user['creator_email']) {
         $body .= "\n\n" . $this->_AppUI->_('Creator', UI_OUTPUT_RAW) . ':' . "\n" . $user['creator_name'] . ', ' . $user['creator_email'];
     }
     $body .= "\n\n" . $this->_AppUI->_('Owner', UI_OUTPUT_RAW) . ':' . "\n" . $user['owner_name'] . ', ' . $user['owner_email'];
     if (isset($comment) && $comment != '') {
         $body .= "\n\n" . $comment;
     }
     return $body;
 }
        $prefs['style'] = $prefs['theme'];
    }
} else {
    $allowMsgs = 'n';
}
if (isset($_SERVER['REMOTE_ADDR'])) {
    $IP = $_SERVER['REMOTE_ADDR'];
    $smarty->assign('IP', $IP);
}
if ($prefs['users_prefs_display_timezone'] == 'Site' || isset($user_preferences[$user]['display_timezone']) && $user_preferences[$user]['display_timezone'] == 'Site') {
    // Everybody stays in the time zone of the server
    $prefs['display_timezone'] = $prefs['server_timezone'];
} elseif (!isset($user_preferences[$user]['display_timezone']) || $user_preferences[$user]['display_timezone'] == '') {
    // If the display timezone is not known ...
    if (isset($_COOKIE['local_tz']) && eregi('[A-Z]', $_COOKIE['local_tz'])) {
        //   ... we try to use the timezone detected by javascript and stored in cookies
        if ($_COOKIE['local_tz'] == 'CEST' || $_COOKIE['local_tz'] == 'HAEC') {
            // CEST (and HAEC, returned by Safari on Mac) is not recognized as a DST timezone (with daylightsavings) by PEAR Date
            //  ... So use one equivalent timezone name
            $prefs['display_timezone'] = 'Europe/Paris';
        } else {
            $prefs['display_timezone'] = $_COOKIE['local_tz'];
        }
        if (!Date_TimeZone::isValidID($prefs['display_timezone'])) {
            $prefs['display_timezone'] = $prefs['server_timezone'];
        }
    } else {
        // ... and we fallback to the server timezone if the cookie value is not available
        $prefs['display_timezone'] = $prefs['server_timezone'];
    }
}
Beispiel #14
0
 /**
  * Method used to get the full list of available timezones to be
  * presented to the user.
  *
  * @access  public
  * @return  array The list of timezones
  */
 function getTimezoneList()
 {
     return Date_TimeZone::getAvailableIDs();
 }
 /**
  * Sets the time zone of this date with the given time zone id
  *
  * Sets the time zone of this date with the given
  * time zone id, or to the system default if the
  * given id is invalid. Does not alter the date/time,
  * only assigns a new time zone.  For conversion, use
  * convertTZ().
  *
  * @access public
  * @param string id a time zone id
  */
 function setTZbyID($id)
 {
     if (Date_TimeZone::isValidID($id)) {
         $this->tz = new Date_TimeZone($id);
     } else {
         $this->tz = Date_TimeZone::getDefault();
     }
 }
Beispiel #16
0
<?php

require_once 'Date.php';
$_DATE_TIMEZONE_DEFAULT = 'Pacific/Chatham';
$tz = Date_TimeZone::getDefault();
if ($tz->id != $_DATE_TIMEZONE_DEFAULT && $tz->id != 'Pacific/Chatham') {
    echo "setDefault Failed\n";
}
Date_TimeZone::setDefault('CST');
$default = 'EST';
$tz = Date_TimeZone::getDefault();
if ($tz->id != $_DATE_TIMEZONE_DEFAULT && $tz->id != 'EST') {
    echo "setDefault Failed\n";
}
Beispiel #17
0
 /**
  * Is this time zone equivalent to another
  *
  * Tests to see if this time zone is equivalent to a given time zone object.
  * Equivalence in this context consists in the two time zones having:
  *
  *  an equal offset from UTC in both standard and Summer time (if
  *   the time zones observe Summer time)
  *  the same Summer time start and end rules, that is, the two time zones
  *   must switch from standard time to Summer time, and vice versa, on the
  *   same day and at the same time
  *
  * @param object $pm_tz the Date_TimeZone object to test, or a valid time
  *                       zone ID
  *
  * @return   bool       true if this time zone is equivalent to the supplied
  *                       time zone
  * @access   public
  */
 function isEquivalent($pm_tz)
 {
     if (is_a($pm_tz, "Date_TimeZone")) {
         if ($pm_tz->getID() == $this->id) {
             return true;
         }
     } else {
         if (!Date_TimeZone::isValidID($pm_tz)) {
             return PEAR::raiseError("Invalid time zone ID '{$pm_tz}'", DATE_ERROR_INVALIDTIMEZONE);
         }
         if ($pm_tz == $this->id) {
             return true;
         }
         $pm_tz = new Date_TimeZone($pm_tz);
     }
     if ($this->getRawOffset() == $pm_tz->getRawOffset() && $this->hasDaylightTime() == $pm_tz->hasDaylightTime() && $this->getDSTSavings() == $pm_tz->getDSTSavings() && $this->getSummerTimeStartMonth() == $pm_tz->getSummerTimeStartMonth() && $this->getSummerTimeStartDay() == $pm_tz->getSummerTimeStartDay() && $this->getSummerTimeStartTime() == $pm_tz->getSummerTimeStartTime() && $this->getSummerTimeEndMonth() == $pm_tz->getSummerTimeEndMonth() && $this->getSummerTimeEndDay() == $pm_tz->getSummerTimeEndDay() && $this->getSummerTimeEndTime() == $pm_tz->getSummerTimeEndTime()) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #18
0
 /**
  * Sets the system default time zone to the time zone in $id
  *
  * @access public
  * @param string $id the time zone id to use
  */
 public static function setDefault($id)
 {
     global $default;
     if ($res = Date_TimeZone::isValidID($id)) {
         $default = $id;
     }
 }
 /**
  * Sets the system default time zone to the time zone in $id
  *
  * Sets the system default time zone to the time zone in $id
  *
  * @access public
  * @param string $id the time zone id to use
  */
 function setDefault($id)
 {
     global $_DATE_TIMEZONE_DEFAULT;
     if (Date_TimeZone::isValidID($id)) {
         $_DATE_TIMEZONE_DEFAULT = $id;
     }
 }
Beispiel #20
0
 public static function convertTimeZone($epoch, $timezone)
 {
     if ($timezone == '') {
         return $epoch;
     }
     $old_timezone_offset = TTDate::getTimeZoneOffset();
     try {
         //Use PEAR Date class to convert timezones instead of PHP v5.2 date object so we can still use older PHP versions for distros like CentOS.
         require_once 'Date.php';
         $d = new Date(date('r', $epoch));
         $tz = new Date_TimeZone($timezone);
         $new_timezone_offset = $tz->getOffset($d) / 1000;
         return $epoch - ($old_timezone_offset - $new_timezone_offset);
     } catch (Exception $e) {
         return $epoch;
     }
     return $epoch;
 }
Beispiel #21
0
 /**
  * Sets the system default time zone to the time zone in $id
  *
  * Sets the system default time zone to the time zone in $id
  *
  * @access public
  * @param string $id the time zone id to use
  */
 function setDefault($id)
 {
     if (Date_TimeZone::isValidID($id)) {
         $GLOBALS['_DATE_TIMEZONE_DEFAULT'] = $id;
     }
 }
Beispiel #22
0
 /**
  * Converts this date to a new time zone, given a valid time zone ID
  *
  * Converts this date to a new time zone, given a valid time zone ID
  * WARNING: This may not work correctly if your system does not allow
  * putenv() or if localtime() does not work in your environment.  See
  * Date::TimeZone::inDaylightTime() for more information.
  *
  * @access public
  * @param string id a time zone id
  */
 function convertTZbyID($id)
 {
     if (Date_TimeZone::isValidID($id)) {
         $tz = new Date_TimeZone($id);
     } else {
         $timezone = new Date_TimeZone('UTC');
         $tz = $timezone->getDefault();
     }
     $this->convertTZ($tz);
 }