]>
src.bluestatic.org Git - isso.git/blob - date.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * Date formatting system
30 * Defined constant time
32 define('TIMENOW', time());
35 * Date Formatting System
37 * This framework handles the complexities of date and time formatting
38 * by taking variables like global timezone and user timezone, then
39 * adjusting timestamps accordingly.
42 * @copyright Copyright ©2002 - [#]year[#], Blue Static
50 * Framework registry object
53 private $registry = null;
56 * User timezone offset
62 * Server's timezone offset; this is set using fetch_offset()
65 private $servertz = 0;
68 * Total offset timezone; this is set using fetch_offset()
71 private $offsettz = 0;
74 * Offset in seconds; this is set using fetch_offset()
80 * Fields array that is used in this module
83 private $fields = array(
84 'usertz' => array(REQ_NO
, null, false)
87 // ###################################################################
89 * Constructor: sets the server's timezone
91 public function __construct(&$registry)
93 $this->registry
=& $registry;
95 $this->servertz
= date('Z', TIMENOW
) / 3600;
98 // ###################################################################
102 * @param string Field name
103 * @param mixed Value of the field
105 public function set($name, $value)
107 $this->registry
->do_set($name, $value, 'date');
110 // ###################################################################
114 * @param string Field name
116 * @return mixed Value of the field
118 public function get($fieldname)
120 return $this->registry
->do_get($fieldname, 'date');
123 // ###################################################################
125 * Computes the total offset, taking into account all the various
128 public function fetch_offset()
130 $this->offsettz
= $this->servertz
- $this->usertz
;
131 $this->offset
= $this->offsettz
* 3600;
134 // ###################################################################
136 * Formats a UNIX timestamp to a certain date format in the proper time
139 * @param string Format of the date (same as PHP's date() function)
140 * @param integer UNIX timestamp to format
141 * @param bool Adjust the date to the user's language?
143 * @return string Formatted date
145 public function format($format, $timestamp = TIMENOW
, $adjust = true)
149 $timestamp -= $this->offset
;
152 return date($format, $timestamp);
155 // ###################################################################
157 * Fetches an array of timezones for a <select> list
159 * @return array List of timezones
161 public function fetch_timezone_list()
165 $opt['-12'] = $this->registry
->modules
['localize']->string('(GMT - 12:00) Enitwetok, Kwajalien');
166 $opt['-11'] = $this->registry
->modules
['localize']->string('(GMT - 11:00) Midway Island, Samoa');
167 $opt['-10'] = $this->registry
->modules
['localize']->string('(GMT - 10:00) Hawaii');
168 $opt['-9'] = $this->registry
->modules
['localize']->string('(GMT - 9:00) Alaska');
169 $opt['-8'] = $this->registry
->modules
['localize']->string('(GMT - 8:00) Pacific Time (US & Canada)');
170 $opt['-7'] = $this->registry
->modules
['localize']->string('(GMT - 7:00) Mountain Time (US & Canada)');
171 $opt['-6'] = $this->registry
->modules
['localize']->string('(GMT - 6:00) Central Time (US & Canada)');
172 $opt['-5'] = $this->registry
->modules
['localize']->string('(GMT - 5:00) Eastern Time (US & Canada)');
173 $opt['-4'] = $this->registry
->modules
['localize']->string('(GMT - 4:00) Atlantic Time (Canada)');
174 $opt['-3.5'] = $this->registry
->modules
['localize']->string('(GMT - 3:30) Newfoundland');
175 $opt['-3'] = $this->registry
->modules
['localize']->string('(GMT - 3:00) Brazil, Buenos Aires, Georgetown');
176 $opt['-2'] = $this->registry
->modules
['localize']->string('(GMT - 2:00) Mid-Atlantic, St. Helena');
177 $opt['-1'] = $this->registry
->modules
['localize']->string('(GMT - 1:00) Azores, Cape Verde Islands');
178 $opt['0'] = $this->registry
->modules
['localize']->string('(GMT) London, Dublin, Casablanca');
179 $opt['1'] = $this->registry
->modules
['localize']->string('(GMT + 1:00) Berlin, Madrid, Paris');
180 $opt['2'] = $this->registry
->modules
['localize']->string('(GMT + 2:00) Kaliningrad, South Africa, Warsaws');
181 $opt['3'] = $this->registry
->modules
['localize']->string('(GMT + 3:00) Baghdad, Moscow, Nairobi');
182 $opt['3.5'] = $this->registry
->modules
['localize']->string('(GMT + 3:30) Tehran');
183 $opt['4'] = $this->registry
->modules
['localize']->string('(GMT + 4:00) Abu Dhabi, Tbilisi, Muscat');
184 $opt['4.5'] = $this->registry
->modules
['localize']->string('(GMT + 4:30) Kabul');
185 $opt['5'] = $this->registry
->modules
['localize']->string('(GMT + 5:00) Ekaterinburg, Islamabad, Tashkent');
186 $opt['5.5'] = $this->registry
->modules
['localize']->string('(GMT + 5:30) Calcutta, Madras, New Delhi');
187 $opt['6'] = $this->registry
->modules
['localize']->string('(GMT + 6:00) Almaty, Colomba, Dhakra');
188 $opt['7'] = $this->registry
->modules
['localize']->string('(GMT + 7:00) Bangkok, Hanoi, Jakarta');
189 $opt['8'] = $this->registry
->modules
['localize']->string('(GMT + 8:00) Beijing, Hong Kong, Singapore');
190 $opt['9'] = $this->registry
->modules
['localize']->string('(GMT + 9:00) Seoul, Tokyo, Yakutsk');
191 $opt['9.5'] = $this->registry
->modules
['localize']->string('(GMT + 9:30) Adelaide, Darwin');
192 $opt['10'] = $this->registry
->modules
['localize']->string('(GMT + 10:00) Guam, Papua New Guinea, Sydney');
193 $opt['11'] = $this->registry
->modules
['localize']->string('(GMT + 11:00) Magadan, New Caledonia, Solomon Islands');
194 $opt['12'] = $this->registry
->modules
['localize']->string('(GMT + 12:00) Auckland, Wellington, Fiji');
200 /*=====================================================================*\
201 || ###################################################################
204 || ###################################################################
205 \*=====================================================================*/