]>
src.bluestatic.org Git - isso.git/blob - date.php
2 /*=====================================================================*\
3 || ################################################################### ||
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 * Global timezone offset for the application; used when there is no usertimezone
51 * User timezone offset
57 * Server's timezone offset
63 * Total offset timezone
76 * Constructor: sets the server's timezone
78 function Date_Formatter()
80 $this->servertz
= date('Z', TIMENOW
) / 3600;
84 * Computes the total offset, taking into account all
87 function fetch_offset()
89 $this->offsettz
= $this->servertz
- $this->usertz
;
90 $this->offset
= $this->offsettz
* 3600;
94 * Formats a UNIX timestamp to a certain date format in the proper time zone
96 * @param string Format of the date (same as PHP's date() function)
97 * @param int UNIX timestamp to format
98 * @param bool Adjust the date to the user's language?
100 * @return string Formatted date
102 function format($format, $timestamp = TIMENOW
, $adjust = true)
106 $timestamp -= $this->offset
;
109 return date($format, $timestamp);
113 /*=====================================================================*\
114 || ###################################################################
117 || ###################################################################
118 \*=====================================================================*/