\*=====================================================================*/
/**
-* Date formatting system
-* date.php
+* Date formatting system (Date.php)
*
* @package ISSO
*/
/**
* Date Formatting System
*
-* This framework handles the complexities of date and time formatting
-* by taking variables like global timezone and user timezone, then
-* adjusting timestamps accordingly.
+* 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 ©2002 - [#]year[#], Blue Static
* @package ISSO
*
*/
-class Date
+class BSDate
{
/**
* Framework registry object
/**
* User timezone offset
- * @var integer
+ * @var float
*/
- public $usertz = 0;
+ private $usertz = 0;
/**
- * Server's timezone offset; this is set using fetch_offset()
- * @var integer
+ * The server's timezone offset
+ * @var float
*/
- private $servertz = 0;
+ private $servertz;
/**
* Total offset timezone; this is set using fetch_offset()
- * @var integer
+ * @var float
*/
private $offsettz = 0;
* @var integer
*/
private $offset = 0;
-
- /**
- * Fields array that is used in this module
- * @var array
- */
- private $fields = array(
- 'usertz' => array(REQ_NO, null, false)
- );
-
+
// ###################################################################
/**
* Constructor: sets the server's timezone
*/
- public function __construct(&$registry)
+ public function __construct()
{
- $this->registry =& $registry;
-
$this->servertz = date('Z', TIMENOW) / 3600;
}
// ###################################################################
/**
- * Sets an ISSO field
- *
- * @param string Field name
- * @param mixed Value of the field
- */
- public function set($name, $value)
- {
- $this->registry->do_set($name, $value, 'date');
- }
-
- // ###################################################################
- /**
- * Gets an ISSO field
- *
- * @param string Field name
+ * Sets the user time zone and then calculates the total offset
*
- * @return mixed Value of the field
- */
- public function get($fieldname)
- {
- return $this->registry->do_get($fieldname, 'date');
- }
-
- // ###################################################################
- /**
- * Computes the total offset, taking into account all the various
- * options
+ * @param float User time zone
*/
- public function fetch_offset()
+ public function setUserTimeZone($usertz)
{
- $this->offsettz = $this->servertz - $this->usertz;
+ $this->usertz = $usertz;
+ $this->offsettz = $this->usertz - $this->servertz;
$this->offset = $this->offsettz * 3600;
}
{
if ($adjust)
{
- $timestamp -= $this->offset;
+ $timestamp += $this->offset;
}
-
- return date($format, $timestamp);
+ return gmdate($format, $timestamp);
}
// ###################################################################
/**
- * Fetches an array of timezones for a <select> list
+ * Fetches an array of timezone names indexed by their offset
*
* @return array List of timezones
*/
- public function fetch_timezone_list()
+ public static function FetchTimeZoneList()
{
$opt = array();
- $opt['-12'] = $this->registry->modules['localize']->string('(GMT - 12:00) Enitwetok, Kwajalien');
- $opt['-11'] = $this->registry->modules['localize']->string('(GMT - 11:00) Midway Island, Samoa');
- $opt['-10'] = $this->registry->modules['localize']->string('(GMT - 10:00) Hawaii');
- $opt['-9'] = $this->registry->modules['localize']->string('(GMT - 9:00) Alaska');
- $opt['-8'] = $this->registry->modules['localize']->string('(GMT - 8:00) Pacific Time (US & Canada)');
- $opt['-7'] = $this->registry->modules['localize']->string('(GMT - 7:00) Mountain Time (US & Canada)');
- $opt['-6'] = $this->registry->modules['localize']->string('(GMT - 6:00) Central Time (US & Canada)');
- $opt['-5'] = $this->registry->modules['localize']->string('(GMT - 5:00) Eastern Time (US & Canada)');
- $opt['-4'] = $this->registry->modules['localize']->string('(GMT - 4:00) Atlantic Time (Canada)');
- $opt['-3.5'] = $this->registry->modules['localize']->string('(GMT - 3:30) Newfoundland');
- $opt['-3'] = $this->registry->modules['localize']->string('(GMT - 3:00) Brazil, Buenos Aires, Georgetown');
- $opt['-2'] = $this->registry->modules['localize']->string('(GMT - 2:00) Mid-Atlantic, St. Helena');
- $opt['-1'] = $this->registry->modules['localize']->string('(GMT - 1:00) Azores, Cape Verde Islands');
- $opt['0'] = $this->registry->modules['localize']->string('(GMT) London, Dublin, Casablanca');
- $opt['1'] = $this->registry->modules['localize']->string('(GMT + 1:00) Berlin, Madrid, Paris');
- $opt['2'] = $this->registry->modules['localize']->string('(GMT + 2:00) Kaliningrad, South Africa, Warsaws');
- $opt['3'] = $this->registry->modules['localize']->string('(GMT + 3:00) Baghdad, Moscow, Nairobi');
- $opt['3.5'] = $this->registry->modules['localize']->string('(GMT + 3:30) Tehran');
- $opt['4'] = $this->registry->modules['localize']->string('(GMT + 4:00) Abu Dhabi, Tbilisi, Muscat');
- $opt['4.5'] = $this->registry->modules['localize']->string('(GMT + 4:30) Kabul');
- $opt['5'] = $this->registry->modules['localize']->string('(GMT + 5:00) Ekaterinburg, Islamabad, Tashkent');
- $opt['5.5'] = $this->registry->modules['localize']->string('(GMT + 5:30) Calcutta, Madras, New Delhi');
- $opt['6'] = $this->registry->modules['localize']->string('(GMT + 6:00) Almaty, Colomba, Dhakra');
- $opt['7'] = $this->registry->modules['localize']->string('(GMT + 7:00) Bangkok, Hanoi, Jakarta');
- $opt['8'] = $this->registry->modules['localize']->string('(GMT + 8:00) Beijing, Hong Kong, Singapore');
- $opt['9'] = $this->registry->modules['localize']->string('(GMT + 9:00) Seoul, Tokyo, Yakutsk');
- $opt['9.5'] = $this->registry->modules['localize']->string('(GMT + 9:30) Adelaide, Darwin');
- $opt['10'] = $this->registry->modules['localize']->string('(GMT + 10:00) Guam, Papua New Guinea, Sydney');
- $opt['11'] = $this->registry->modules['localize']->string('(GMT + 11:00) Magadan, New Caledonia, Solomon Islands');
- $opt['12'] = $this->registry->modules['localize']->string('(GMT + 12:00) Auckland, Wellington, Fiji');
+ $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;
}