]>
src.bluestatic.org Git - isso.git/blob - date.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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.
41 * @author Iris Studios, Inc.
42 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
50 * Framework registry object
57 * User timezone offset
64 * Server's timezone offset; this is set using fetch_offset()
71 * Total offset timezone; this is set using fetch_offset()
78 * Offset in seconds; this is set using fetch_offset()
85 * Fields array that is used in this module
90 'usertz' => array(REQ_NO
, null, false)
93 // ###################################################################
95 * Constructor: sets the server's timezone
97 function __construct(&$registry)
99 $this->registry
=& $registry;
101 $this->servertz
= date('Z', TIMENOW
) / 3600;
104 // ###################################################################
106 * (PHP 4) Constructor
108 function Date(&$registry)
110 $this->__construct($registry);
113 // ###################################################################
119 * @param string Field name
120 * @param mixed Value of the field
122 function set($name, $value)
124 $this->registry
->do_set($name, $value, 'date');
127 // ###################################################################
129 * Computes the total offset, taking into account all the various
134 function fetch_offset()
136 $this->offsettz
= $this->servertz
- $this->usertz
;
137 $this->offset
= $this->offsettz
* 3600;
140 // ###################################################################
142 * Formats a UNIX timestamp to a certain date format in the proper time
147 * @param string Format of the date (same as PHP's date() function)
148 * @param integer UNIX timestamp to format
149 * @param bool Adjust the date to the user's language?
151 * @return string Formatted date
153 function format($format, $timestamp = TIMENOW
, $adjust = true)
157 $timestamp -= $this->offset
;
160 return date($format, $timestamp);
163 // ###################################################################
165 * Fetches an array of timezones for a <select> list
169 * @return array List of timezones
171 function fetch_timezone_list()
175 $opt['-12'] = '(GMT - 12:00) Enitwetok, Kwajalien';
176 $opt['-11'] = '(GMT - 11:00) Midway Island, Samoa';
177 $opt['-10'] = '(GMT - 10:00) Hawaii';
178 $opt['-9'] = '(GMT - 9:00) Alaska';
179 $opt['-8'] = '(GMT - 8:00) Pacific Time (US & Canada)';
180 $opt['-7'] = '(GMT - 7:00) Mountain Time (US & Canada)';
181 $opt['-6'] = '(GMT - 6:00) Central Time (US & Canada)';
182 $opt['-5'] = '(GMT - 5:00) Eastern Time (US & Canada)';
183 $opt['-4'] = '(GMT - 4:00) Atlantic Time (Canada)';
184 $opt['-3.5'] = '(GMT - 3:30) Newfoundland';
185 $opt['-3'] = '(GMT - 3:00) Brazil, Buenos Aires, Georgetown';
186 $opt['-2'] = '(GMT - 2:00) Mid-Atlantic, St. Helena';
187 $opt['-1'] = '(GMT - 1:00) Azores, Cape Verde Islands';
188 $opt['0'] = '(GMT) London, Dublin, Casablanca';
189 $opt['1'] = '(GMT + 1:00) Berlin, Madrid, Paris';
190 $opt['2'] = '(GMT + 2:00) Kaliningrad, South Africa, Warsaws';
191 $opt['3'] = '(GMT + 3:00) Baghdad, Moscow, Nairobi';
192 $opt['3.5'] = '(GMT + 3:30) Tehran';
193 $opt['4'] = '(GMT + 4:00) Abu Dhabi, Tbilisi, Muscat';
194 $opt['4.5'] = '(GMT + 4:30) Kabul';
195 $opt['5'] = '(GMT + 5:00) Ekaterinburg, Islamabad, Tashkent';
196 $opt['5.5'] = '(GMT + 5:30) Calcutta, Madras, New Delhi';
197 $opt['6'] = '(GMT + 6:00) Almaty, Colomba, Dhakra';
198 $opt['7'] = '(GMT + 7:00) Bangkok, Hanoi, Jakarta';
199 $opt['8'] = '(GMT + 8:00) Beijing, Hong Kong, Singapore';
200 $opt['9'] = '(GMT + 9:00) Seoul, Tokyo, Yakutsk';
201 $opt['9.5'] = '(GMT + 9:30) Adelaide, Darwin';
202 $opt['10'] = '(GMT + 10:00) Guam, Papua New Guinea, Sydney';
203 $opt['11'] = '(GMT + 11:00) Magadan, New Caledonia, Solomon Islands';
204 $opt['12'] = '(GMT + 12:00) Auckland, Wellington, Fiji';
210 /*=====================================================================*\
211 || ###################################################################
214 || ###################################################################
215 \*=====================================================================*/