Cleaning up phpDoc variable declarations
[isso.git] / date.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 /**
23 * Date formatting system
24 * date.php
25 *
26 * @package ISSO
27 */
28
29 $OBJECT = 'Date Formatting System';
30 $CLASS = 'Date_Formatter';
31 $OBJ = 'datef';
32
33 /**
34 * Defined constant time
35 */
36 define('TIMENOW', time());
37
38 /**
39 * Date Formatting System
40 *
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.
44 *
45 * @author Iris Studios, Inc.
46 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
47 * @version $Revision$
48 * @package ISSO
49 *
50 */
51 class Date_Formatter
52 {
53 /**
54 * User timezone offset
55 * @var integer
56 */
57 var $usertz = 0;
58
59 /**
60 * Server's timezone offset
61 * @var integer
62 */
63 var $servertz = 0;
64
65 /**
66 * Total offset timezone
67 * @var integer
68 * @see fetch_offset()
69 */
70 var $offsettz = 0;
71
72 /**
73 * Offset in seconds
74 * @var integer
75 */
76 var $offset = 0;
77
78 /**
79 * Constructor: sets the server's timezone
80 */
81 function Date_Formatter()
82 {
83 $this->servertz = date('Z', TIMENOW) / 3600;
84 }
85
86 /**
87 * Computes the total offset, taking into account all
88 * the various options
89 */
90 function fetch_offset()
91 {
92 $this->offsettz = $this->servertz - $this->usertz;
93 $this->offset = $this->offsettz * 3600;
94 }
95
96 /**
97 * Formats a UNIX timestamp to a certain date format in the proper time zone
98 *
99 * @param string Format of the date (same as PHP's date() function)
100 * @param integer UNIX timestamp to format
101 * @param bool Adjust the date to the user's language?
102 *
103 * @return string Formatted date
104 */
105 function format($format, $timestamp = TIMENOW, $adjust = true)
106 {
107 if ($adjust)
108 {
109 $timestamp -= $this->offset;
110 }
111
112 return date($format, $timestamp);
113 }
114 }
115
116 /*=====================================================================*\
117 || ###################################################################
118 || # $HeadURL$
119 || # $Id$
120 || ###################################################################
121 \*=====================================================================*/
122 ?>