]>
src.bluestatic.org Git - isso.git/blob - date.php
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 /*=====================================================================*\
108 || ###################################################################
111 || ###################################################################
112 \*=====================================================================*/