|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */ |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Contains the Calendar_Engine_Interface class (interface). |
|
7
|
|
|
* |
|
8
|
|
|
* PHP versions 4 and 5 |
|
9
|
|
|
* |
|
10
|
|
|
* LICENSE: Redistribution and use in source and binary forms, with or without |
|
11
|
|
|
* modification, are permitted provided that the following conditions are met: |
|
12
|
|
|
* 1. Redistributions of source code must retain the above copyright |
|
13
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
14
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
|
15
|
|
|
* notice, this list of conditions and the following disclaimer in the |
|
16
|
|
|
* documentation and/or other materials provided with the distribution. |
|
17
|
|
|
* 3. The name of the author may not be used to endorse or promote products |
|
18
|
|
|
* derived from this software without specific prior written permission. |
|
19
|
|
|
* |
|
20
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED |
|
21
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
22
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
23
|
|
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY |
|
24
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
25
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
26
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
27
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
28
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
29
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
30
|
|
|
* |
|
31
|
|
|
* @category Date and Time |
|
32
|
|
|
* |
|
33
|
|
|
* @author Harry Fuecks <[email protected]> |
|
34
|
|
|
* @author Lorenzo Alberton <[email protected]> |
|
35
|
|
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
|
36
|
|
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
|
37
|
|
|
* |
|
38
|
|
|
* @link http://pear.php.net/package/Calendar |
|
39
|
|
|
*/ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* The methods the classes implementing the Calendar_Engine must implement. |
|
43
|
|
|
* Note this class is not used but simply to help development. |
|
44
|
|
|
* |
|
45
|
|
|
* @category Date and Time |
|
46
|
|
|
* |
|
47
|
|
|
* @author Harry Fuecks <[email protected]> |
|
48
|
|
|
* @author Lorenzo Alberton <[email protected]> |
|
49
|
|
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
|
50
|
|
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
|
51
|
|
|
* |
|
52
|
|
|
* @link http://pear.php.net/package/Calendar |
|
53
|
|
|
*/ |
|
54
|
|
|
class Calendar_Engine_Interface |
|
55
|
|
|
{ |
|
56
|
|
|
/** |
|
57
|
|
|
* Provides a mechansim to make sure parsing of timestamps |
|
58
|
|
|
* into human dates is only performed once per timestamp. |
|
59
|
|
|
* Typically called "internally" by methods like stampToYear. |
|
60
|
|
|
* Return value can vary, depending on the specific implementation. |
|
61
|
|
|
* |
|
62
|
|
|
* @param int $stamp timestamp (depending on implementation) |
|
63
|
|
|
* |
|
64
|
|
|
* @return mixed |
|
65
|
|
|
*/ |
|
66
|
|
|
public function stampCollection($stamp) |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Returns a numeric year given a timestamp. |
|
72
|
|
|
* |
|
73
|
|
|
* @param int $stamp timestamp (depending on implementation) |
|
74
|
|
|
*/ |
|
75
|
|
|
public function stampToYear($stamp) |
|
|
|
|
|
|
76
|
|
|
{ |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Returns a numeric month given a timestamp. |
|
81
|
|
|
* |
|
82
|
|
|
* @param int $stamp timestamp (depending on implementation) |
|
83
|
|
|
*/ |
|
84
|
|
|
public function stampToMonth($stamp) |
|
|
|
|
|
|
85
|
|
|
{ |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Returns a numeric day given a timestamp. |
|
90
|
|
|
* |
|
91
|
|
|
* @param int $stamp timestamp (depending on implementation) |
|
92
|
|
|
*/ |
|
93
|
|
|
public function stampToDay($stamp) |
|
|
|
|
|
|
94
|
|
|
{ |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Returns a numeric hour given a timestamp. |
|
99
|
|
|
* |
|
100
|
|
|
* @param int $stamp timestamp (depending on implementation) |
|
101
|
|
|
*/ |
|
102
|
|
|
public function stampToHour($stamp) |
|
|
|
|
|
|
103
|
|
|
{ |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Returns a numeric minute given a timestamp. |
|
108
|
|
|
* |
|
109
|
|
|
* @param int $stamp timestamp (depending on implementation) |
|
110
|
|
|
*/ |
|
111
|
|
|
public function stampToMinute($stamp) |
|
|
|
|
|
|
112
|
|
|
{ |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Returns a numeric second given a timestamp. |
|
117
|
|
|
* |
|
118
|
|
|
* @param int $stamp timestamp (depending on implementation) |
|
119
|
|
|
*/ |
|
120
|
|
|
public function stampToSecond($stamp) |
|
|
|
|
|
|
121
|
|
|
{ |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Returns a timestamp. Can be worth "caching" generated timestamps in a |
|
126
|
|
|
* static variable, identified by the params this method accepts, |
|
127
|
|
|
* to timestamp will only be calculated once. |
|
128
|
|
|
* |
|
129
|
|
|
* @param int $y year (e.g. 2003) |
|
130
|
|
|
* @param int $m month (e.g. 9) |
|
131
|
|
|
* @param int $d day (e.g. 13) |
|
132
|
|
|
* @param int $h hour (e.g. 13) |
|
133
|
|
|
* @param int $i minute (e.g. 34) |
|
134
|
|
|
* @param int $s second (e.g. 53) |
|
135
|
|
|
*/ |
|
136
|
|
|
public function dateToStamp($y, $m, $d, $h, $i, $s) |
|
|
|
|
|
|
137
|
|
|
{ |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* The upper limit on years that the Calendar Engine can work with. |
|
142
|
|
|
*/ |
|
143
|
|
|
public function getMaxYears() |
|
144
|
|
|
{ |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* The lower limit on years that the Calendar Engine can work with. |
|
149
|
|
|
*/ |
|
150
|
|
|
public function getMinYears() |
|
151
|
|
|
{ |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Returns the number of months in a year. |
|
156
|
|
|
* |
|
157
|
|
|
* @param int $y (optional) year to get months for |
|
158
|
|
|
*/ |
|
159
|
|
|
public function getMonthsInYear($y = null) |
|
|
|
|
|
|
160
|
|
|
{ |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Returns the number of days in a month, given year and month. |
|
165
|
|
|
* |
|
166
|
|
|
* @param int $y year (e.g. 2003) |
|
167
|
|
|
* @param int $m month (e.g. 9) |
|
168
|
|
|
*/ |
|
169
|
|
|
public function getDaysInMonth($y, $m) |
|
|
|
|
|
|
170
|
|
|
{ |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Returns numeric representation of the day of the week in a month, |
|
175
|
|
|
* given year and month. |
|
176
|
|
|
* |
|
177
|
|
|
* @param int $y year (e.g. 2003) |
|
178
|
|
|
* @param int $m month (e.g. 9) |
|
179
|
|
|
*/ |
|
180
|
|
|
public function getFirstDayInMonth($y, $m) |
|
|
|
|
|
|
181
|
|
|
{ |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Returns the number of days in a week. |
|
186
|
|
|
* |
|
187
|
|
|
* @param int $y year (2003) |
|
188
|
|
|
* @param int $m month (9) |
|
189
|
|
|
* @param int $d day (4) |
|
190
|
|
|
*/ |
|
191
|
|
|
public function getDaysInWeek($y = null, $m = null, $d = null) |
|
|
|
|
|
|
192
|
|
|
{ |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* Returns the number of the week in the year (ISO-8601), given a date. |
|
197
|
|
|
* |
|
198
|
|
|
* @param int $y year (2003) |
|
199
|
|
|
* @param int $m month (9) |
|
200
|
|
|
* @param int $d day (4) |
|
201
|
|
|
*/ |
|
202
|
|
|
public function getWeekNInYear($y, $m, $d) |
|
|
|
|
|
|
203
|
|
|
{ |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Returns the number of the week in the month, given a date. |
|
208
|
|
|
* |
|
209
|
|
|
* @param int $y year (2003) |
|
210
|
|
|
* @param int $m month (9) |
|
211
|
|
|
* @param int $d day (4) |
|
212
|
|
|
* @param int $firstDay first day of the week (default: 1 - monday) |
|
213
|
|
|
*/ |
|
214
|
|
|
public function getWeekNInMonth($y, $m, $d, $firstDay = 1) |
|
|
|
|
|
|
215
|
|
|
{ |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Returns the number of weeks in the month. |
|
220
|
|
|
* |
|
221
|
|
|
* @param int $y year (2003) |
|
222
|
|
|
* @param int $m month (9) |
|
223
|
|
|
*/ |
|
224
|
|
|
public function getWeeksInMonth($y, $m) |
|
|
|
|
|
|
225
|
|
|
{ |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* Returns the number of the day of the week (0=sunday, 1=monday...). |
|
230
|
|
|
* |
|
231
|
|
|
* @param int $y year (2003) |
|
232
|
|
|
* @param int $m month (9) |
|
233
|
|
|
* @param int $d day (4) |
|
234
|
|
|
*/ |
|
235
|
|
|
public function getDayOfWeek($y, $m, $d) |
|
|
|
|
|
|
236
|
|
|
{ |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* Returns the numeric values of the days of the week. |
|
241
|
|
|
* |
|
242
|
|
|
* @param int $y year (2003) |
|
243
|
|
|
* @param int $m month (9) |
|
244
|
|
|
* @param int $d day (4) |
|
245
|
|
|
*/ |
|
246
|
|
|
public function getWeekDays($y = null, $m = null, $d = null) |
|
|
|
|
|
|
247
|
|
|
{ |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
/** |
|
251
|
|
|
* Returns the default first day of the week as an integer. Must be a |
|
252
|
|
|
* member of the array returned from getWeekDays. |
|
253
|
|
|
* |
|
254
|
|
|
* @param int $y year (2003) |
|
255
|
|
|
* @param int $m month (9) |
|
256
|
|
|
* @param int $d day (4) |
|
257
|
|
|
* |
|
258
|
|
|
* |
|
259
|
|
|
* @see getWeekDays |
|
260
|
|
|
*/ |
|
261
|
|
|
public function getFirstDayOfWeek($y = null, $m = null, $d = null) |
|
|
|
|
|
|
262
|
|
|
{ |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* Returns the number of hours in a day. |
|
267
|
|
|
* |
|
268
|
|
|
* @param int $y year (2003) |
|
269
|
|
|
* @param int $m month (9) |
|
270
|
|
|
* @param int $d day (4) |
|
271
|
|
|
*/ |
|
272
|
|
|
public function getHoursInDay($y = null, $m = null, $d = null) |
|
|
|
|
|
|
273
|
|
|
{ |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* Returns the number of minutes in an hour. |
|
278
|
|
|
* |
|
279
|
|
|
* @param int $y year (2003) |
|
280
|
|
|
* @param int $m month (9) |
|
281
|
|
|
* @param int $d day (4) |
|
282
|
|
|
* @param int $h hour |
|
283
|
|
|
*/ |
|
284
|
|
|
public function getMinutesInHour($y = null, $m = null, $d = null, $h = null) |
|
|
|
|
|
|
285
|
|
|
{ |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
/** |
|
289
|
|
|
* Returns the number of seconds in a minutes. |
|
290
|
|
|
* |
|
291
|
|
|
* @param int $y year (2003) |
|
292
|
|
|
* @param int $m month (9) |
|
293
|
|
|
* @param int $d day (4) |
|
294
|
|
|
* @param int $h hour |
|
295
|
|
|
* @param int $i minute |
|
296
|
|
|
*/ |
|
297
|
|
|
public function getSecondsInMinute($y = null, $m = null, $d = null, $h = null, $i = null) |
|
|
|
|
|
|
298
|
|
|
{ |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* Checks if the given day is the current day. |
|
303
|
|
|
* |
|
304
|
|
|
* @param mixed $stamp |
|
305
|
|
|
*/ |
|
306
|
|
|
public function isToday($stamp) |
|
|
|
|
|
|
307
|
|
|
{ |
|
308
|
|
|
} |
|
309
|
|
|
} |
|
310
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.