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; }
/** * 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; } }
/** * 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); }
/** * 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; } }
/** * 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; } }
/** * 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; } }
/** * 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; } }
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; }
/** * 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; } }
$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']; } }
/** * 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(); } }
/** * 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); }