Removing @see 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 */
69 var $offsettz = 0;
70
71 /**
72 * Offset in seconds
73 * @var integer
74 */
75 var $offset = 0;
76
77 /**
78 * Constructor: sets the server's timezone
79 */
80 function Date_Formatter()
81 {
82 $this->servertz = date('Z', TIMENOW) / 3600;
83 }
84
85 /**
86 * Computes the total offset, taking into account all
87 * the various options
88 */
89 function fetch_offset()
90 {
91 $this->offsettz = $this->servertz - $this->usertz;
92 $this->offset = $this->offsettz * 3600;
93 }
94
95 /**
96 * Formats a UNIX timestamp to a certain date format in the proper time zone
97 *
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?
101 *
102 * @return string Formatted date
103 */
104 function format($format, $timestamp = TIMENOW, $adjust = true)
105 {
106 if ($adjust)
107 {
108 $timestamp -= $this->offset;
109 }
110
111 return date($format, $timestamp);
112 }
113 }
114
115 /*=====================================================================*\
116 || ###################################################################
117 || # $HeadURL$
118 || # $Id$
119 || ###################################################################
120 \*=====================================================================*/
121 ?>