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
29 $OBJECT = 'Date Formatting System';
30 $CLASS = 'Date_Formatter';
34 * Defined constant time
36 define('TIMENOW', time());
39 * Date Formatting System
41 * This framework handles the complexities of date and time formatting
42 * by taking variables like global timezone and user timezone, then
43 * adjusting timestamps accordingly.
45 * @author Iris Studios, Inc.
46 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
54 * User timezone offset
60 * Server's timezone offset
66 * Total offset timezone
78 * Constructor: sets the server's timezone
80 function Date_Formatter()
82 $this->servertz
= date('Z', TIMENOW
) / 3600;
86 * Computes the total offset, taking into account all
89 function fetch_offset()
91 $this->offsettz
= $this->servertz
- $this->usertz
;
92 $this->offset
= $this->offsettz
* 3600;
96 * Formats a UNIX timestamp to a certain date format in the proper time zone
98 * @param string Format of the date (same as PHP's date() function)
99 * @param integer UNIX timestamp to format
100 * @param bool Adjust the date to the user's language?
102 * @return string Formatted date
104 function format($format, $timestamp = TIMENOW
, $adjust = true
)
108 $timestamp -= $this->offset
;
111 return date($format, $timestamp);
115 /*=====================================================================*\
116 || ###################################################################
119 || ###################################################################
120 \*=====================================================================*/