<?php
/*=====================================================================*\
|| ###################################################################
|| # Blue Static ISSO Framework
|| # Copyright (c)2005-2008 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version 2 of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/
/**
* Date formatting system (Date.php)
*
* @package ISSO
*/
/**
* Defined constant time
*/
define('TIMENOW', time());
/**
* Date Formatting System
*
* This framework wraps date and time functions into one neat little
* package that takes care of modifying timestamps to meet the right
* time zone
*
* @author Blue Static
* @copyright Copyright (c)2005 - 2008, Blue Static
* @package ISSO
*
*/
class BSDate
{
/**
* Offset in seconds; this is set using fetch_offset()
* @var integer
*/
private $offset = 0;
/**
* Sets the user time zone and then calculates the total offset
*
* @param float User time zone
*/
public function setUserTimeZone($usertz)
{
$this->offset = $usertz * 3600;
}
/**
* Formats a UNIX timestamp to a certain date format in the proper time
* zone
*
* @param string Format of the date (same as PHP's date() function)
* @param integer UNIX timestamp to format
* @param bool Adjust the date to the user's language?
*
* @return string Formatted date
*/
public function format($format, $timestamp = TIMENOW, $adjust = true)
{
if ($adjust)
{
$timestamp += $this->offset;
}
return gmdate($format, $timestamp);
}
/**
* Fetches an array of timezone names indexed by their offset
*
* @return array List of timezones
*/
public static function fetch_timezone_list()
{
$opt = array();
$opt['-12'] = _('(GMT - 12:00) Enitwetok, Kwajalien');
$opt['-11'] = _('(GMT - 11:00) Midway Island, Samoa');
$opt['-10'] = _('(GMT - 10:00) Hawaii');
$opt['-9'] = _('(GMT - 9:00) Alaska');
$opt['-8'] = _('(GMT - 8:00) Pacific Time (US & Canada)');
$opt['-7'] = _('(GMT - 7:00) Mountain Time (US & Canada)');
$opt['-6'] = _('(GMT - 6:00) Central Time (US & Canada)');
$opt['-5'] = _('(GMT - 5:00) Eastern Time (US & Canada)');
$opt['-4'] = _('(GMT - 4:00) Atlantic Time (Canada)');
$opt['-3.5'] = _('(GMT - 3:30) Newfoundland');
$opt['-3'] = _('(GMT - 3:00) Brazil, Buenos Aires, Georgetown');
$opt['-2'] = _('(GMT - 2:00) Mid-Atlantic, St. Helena');
$opt['-1'] = _('(GMT - 1:00) Azores, Cape Verde Islands');
$opt['0'] = _('(GMT) London, Dublin, Casablanca');
$opt['1'] = _('(GMT + 1:00) Berlin, Madrid, Paris');
$opt['2'] = _('(GMT + 2:00) Kaliningrad, South Africa, Warsaws');
$opt['3'] = _('(GMT + 3:00) Baghdad, Moscow, Nairobi');
$opt['3.5'] = _('(GMT + 3:30) Tehran');
$opt['4'] = _('(GMT + 4:00) Abu Dhabi, Tbilisi, Muscat');
$opt['4.5'] = _('(GMT + 4:30) Kabul');
$opt['5'] = _('(GMT + 5:00) Ekaterinburg, Islamabad, Tashkent');
$opt['5.5'] = _('(GMT + 5:30) Calcutta, Madras, New Delhi');
$opt['6'] = _('(GMT + 6:00) Almaty, Colomba, Dhakra');
$opt['7'] = _('(GMT + 7:00) Bangkok, Hanoi, Jakarta');
$opt['8'] = _('(GMT + 8:00) Beijing, Hong Kong, Singapore');
$opt['9'] = _('(GMT + 9:00) Seoul, Tokyo, Yakutsk');
$opt['9.5'] = _('(GMT + 9:30) Adelaide, Darwin');
$opt['10'] = _('(GMT + 10:00) Guam, Papua New Guinea, Sydney');
$opt['11'] = _('(GMT + 11:00) Magadan, New Caledonia, Solomon Islands');
$opt['12'] = _('(GMT + 12:00) Auckland, Wellington, Fiji');
return $opt;
}
}
?>