2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
14 * Date formatting system
20 $OBJECT = 'Date Formatting System';
21 $CLASS = 'Date_Formatter';
25 * Defined constant time
27 define('TIMENOW', time());
30 * Date Formatting System
32 * This framework handles the complexities of date and time formatting
33 * by taking variables like global timezone and user timezone, then
34 * adjusting timestamps accordingly.
36 * @author Iris Studios, Inc.
37 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
45 * User timezone offset
51 * Server's timezone offset
57 * Total offset timezone
70 * Constructor: sets the server's timezone
72 function Date_Formatter()
74 $this->servertz
= date('Z', TIMENOW
) / 3600;
78 * Computes the total offset, taking into account all
81 function fetch_offset()
83 $this->offsettz
= $this->servertz
- $this->usertz
;
84 $this->offset
= $this->offsettz
* 3600;
88 * Formats a UNIX timestamp to a certain date format in the proper time zone
90 * @param string Format of the date (same as PHP's date() function)
91 * @param int UNIX timestamp to format
92 * @param bool Adjust the date to the user's language?
94 * @return string Formatted date
96 function format($format, $timestamp = TIMENOW
, $adjust = true
)
100 $timestamp -= $this->offset
;
103 return date($format, $timestamp);
107 * Fetches an array of timezones for a <select> list
109 * @return array List of timezones
111 function fetch_timezone_list()
115 $opt['-12'] = '(GMT - 12:00) Enitwetok, Kwajalien';
116 $opt['-11'] = '(GMT - 11:00) Midway Island, Samoa';
117 $opt['-10'] = '(GMT - 10:00) Hawaii';
118 $opt['-9'] = '(GMT - 9:00) Alaska';
119 $opt['-8'] = '(GMT - 8:00) Pacific Time (US & Canada)';
120 $opt['-7'] = '(GMT - 7:00) Mountain Time (US & Canada)';
121 $opt['-6'] = '(GMT - 6:00) Central Time (US & Canada)';
122 $opt['-5'] = '(GMT - 5:00) Eastern Time (US & Canada)';
123 $opt['-4'] = '(GMT - 4:00) Atlantic Time (Canada)';
124 $opt['-3.5'] = '(GMT - 3:30) Newfoundland';
125 $opt['-3'] = '(GMT - 3:00) Brazil, Buenos Aires, Georgetown';
126 $opt['-2'] = '(GMT - 2:00) Mid-Atlantic, St. Helena';
127 $opt['-1'] = '(GMT - 1:00) Azores, Cape Verde Islands';
128 $opt['0'] = '(GMT) London, Dublin, Casablanca';
129 $opt['1'] = '(GMT + 1:00) Berlin, Madrid, Paris';
130 $opt['2'] = '(GMT + 2:00) Kaliningrad, South Africa, Warsaws';
131 $opt['3'] = '(GMT + 3:00) Baghdad, Moscow, Nairobi';
132 $opt['3.5'] = '(GMT + 3:30) Tehran';
133 $opt['4'] = '(GMT + 4:00) Abu Dhabi, Tbilisi, Muscat';
134 $opt['4.5'] = '(GMT + 4:30) Kabul';
135 $opt['5'] = '(GMT + 5:00) Ekaterinburg, Islamabad, Tashkent';
136 $opt['5.5'] = '(GMT + 5:30) Calcutta, Madras, New Delhi';
137 $opt['6'] = '(GMT + 6:00) Almaty, Colomba, Dhakra';
138 $opt['7'] = '(GMT + 7:00) Bangkok, Hanoi, Jakarta';
139 $opt['8'] = '(GMT + 8:00) Beijing, Hong Kong, Singapore';
140 $opt['9'] = '(GMT + 9:00) Seoul, Tokyo, Yakutsk';
141 $opt['9.5'] = '(GMT + 9:30) Adelaide, Darwin';
142 $opt['10'] = '(GMT + 10:00) Guam, Papua New Guinea, Sydney';
143 $opt['11'] = '(GMT + 11:00) Magadan, New Caledonia, Solomon Islands';
144 $opt['12'] = '(GMT + 12:00) Auckland, Wellington, Fiji';
150 /*=====================================================================*\
151 || ###################################################################
154 || ###################################################################
155 \*=====================================================================*/