1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Contains the Calendar_Engine_Interface class (interface) |
6
|
|
|
* |
7
|
|
|
* PHP versions 4 and 5 |
8
|
|
|
* |
9
|
|
|
* LICENSE: Redistribution and use in source and binary forms, with or without |
10
|
|
|
* modification, are permitted provided that the following conditions are met: |
11
|
|
|
* 1. Redistributions of source code must retain the above copyright |
12
|
|
|
* notice, this list of conditions and the following disclaimer. |
13
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
14
|
|
|
* notice, this list of conditions and the following disclaimer in the |
15
|
|
|
* documentation and/or other materials provided with the distribution. |
16
|
|
|
* 3. The name of the author may not be used to endorse or promote products |
17
|
|
|
* derived from this software without specific prior written permission. |
18
|
|
|
* |
19
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED |
20
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
21
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22
|
|
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY |
23
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29
|
|
|
* |
30
|
|
|
* @category Date and Time |
31
|
|
|
* @package Calendar |
32
|
|
|
* @author Harry Fuecks <[email protected]> |
33
|
|
|
* @author Lorenzo Alberton <[email protected]> |
34
|
|
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
35
|
|
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
36
|
|
|
* @version CVS: $Id$ |
37
|
|
|
* @link http://pear.php.net/package/Calendar |
38
|
|
|
*/ |
39
|
|
|
namespace PEAR\Calendar\Engine; |
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
|
|
|
* @package Calendar |
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
|
|
|
* @link http://pear.php.net/package/Calendar |
52
|
|
|
* @access protected |
53
|
|
|
*/ |
54
|
|
|
class CalendarEngineInterface |
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
|
|
|
* @access protected |
66
|
|
|
*/ |
67
|
|
|
function stampCollection($stamp) |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Returns a numeric year given a timestamp |
73
|
|
|
* |
74
|
|
|
* @param int $stamp timestamp (depending on implementation) |
75
|
|
|
* |
76
|
|
|
* @return int year (e.g. 2003) |
77
|
|
|
* @access protected |
78
|
|
|
*/ |
79
|
|
|
function stampToYear($stamp) |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Returns a numeric month given a timestamp |
85
|
|
|
* |
86
|
|
|
* @param int $stamp timestamp (depending on implementation) |
87
|
|
|
* |
88
|
|
|
* @return int month (e.g. 9) |
89
|
|
|
* @access protected |
90
|
|
|
*/ |
91
|
|
|
function stampToMonth($stamp) |
|
|
|
|
92
|
|
|
{ |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Returns a numeric day given a timestamp |
97
|
|
|
* |
98
|
|
|
* @param int $stamp timestamp (depending on implementation) |
99
|
|
|
* |
100
|
|
|
* @return int day (e.g. 15) |
101
|
|
|
* @access protected |
102
|
|
|
*/ |
103
|
|
|
function stampToDay($stamp) |
|
|
|
|
104
|
|
|
{ |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Returns a numeric hour given a timestamp |
109
|
|
|
* |
110
|
|
|
* @param int $stamp timestamp (depending on implementation) |
111
|
|
|
* |
112
|
|
|
* @return int hour (e.g. 13) |
113
|
|
|
* @access protected |
114
|
|
|
*/ |
115
|
|
|
function stampToHour($stamp) |
|
|
|
|
116
|
|
|
{ |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Returns a numeric minute given a timestamp |
121
|
|
|
* |
122
|
|
|
* @param int $stamp timestamp (depending on implementation) |
123
|
|
|
* |
124
|
|
|
* @return int minute (e.g. 34) |
125
|
|
|
* @access protected |
126
|
|
|
*/ |
127
|
|
|
function stampToMinute($stamp) |
|
|
|
|
128
|
|
|
{ |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Returns a numeric second given a timestamp |
133
|
|
|
* |
134
|
|
|
* @param int $stamp timestamp (depending on implementation) |
135
|
|
|
* |
136
|
|
|
* @return int second (e.g. 51) |
137
|
|
|
* @access protected |
138
|
|
|
*/ |
139
|
|
|
function stampToSecond($stamp) |
|
|
|
|
140
|
|
|
{ |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Returns a timestamp. Can be worth "caching" generated timestamps in a |
145
|
|
|
* static variable, identified by the params this method accepts, |
146
|
|
|
* to timestamp will only be calculated once. |
147
|
|
|
* |
148
|
|
|
* @param int $y year (e.g. 2003) |
149
|
|
|
* @param int $m month (e.g. 9) |
150
|
|
|
* @param int $d day (e.g. 13) |
151
|
|
|
* @param int $h hour (e.g. 13) |
152
|
|
|
* @param int $i minute (e.g. 34) |
153
|
|
|
* @param int $s second (e.g. 53) |
154
|
|
|
* |
155
|
|
|
* @return int (depends on implementation) |
156
|
|
|
* @access protected |
157
|
|
|
*/ |
158
|
|
|
function dateToStamp($y, $m, $d, $h, $i, $s) |
|
|
|
|
159
|
|
|
{ |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* The upper limit on years that the Calendar Engine can work with |
164
|
|
|
* |
165
|
|
|
* @return int (e.g. 2037) |
166
|
|
|
* @access protected |
167
|
|
|
*/ |
168
|
|
|
function getMaxYears() |
|
|
|
|
169
|
|
|
{ |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* The lower limit on years that the Calendar Engine can work with |
174
|
|
|
* |
175
|
|
|
* @return int (e.g 1902) |
176
|
|
|
* @access protected |
177
|
|
|
*/ |
178
|
|
|
function getMinYears() |
|
|
|
|
179
|
|
|
{ |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Returns the number of months in a year |
184
|
|
|
* |
185
|
|
|
* @param int $y (optional) year to get months for |
186
|
|
|
* |
187
|
|
|
* @return int (e.g. 12) |
188
|
|
|
* @access protected |
189
|
|
|
*/ |
190
|
|
|
function getMonthsInYear($y=null) |
|
|
|
|
191
|
|
|
{ |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Returns the number of days in a month, given year and month |
196
|
|
|
* |
197
|
|
|
* @param int $y year (e.g. 2003) |
198
|
|
|
* @param int $m month (e.g. 9) |
199
|
|
|
* |
200
|
|
|
* @return int days in month |
201
|
|
|
* @access protected |
202
|
|
|
*/ |
203
|
|
|
function getDaysInMonth($y, $m) |
|
|
|
|
204
|
|
|
{ |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Returns numeric representation of the day of the week in a month, |
209
|
|
|
* given year and month |
210
|
|
|
* |
211
|
|
|
* @param int $y year (e.g. 2003) |
212
|
|
|
* @param int $m month (e.g. 9) |
213
|
|
|
* |
214
|
|
|
* @return int |
215
|
|
|
* @access protected |
216
|
|
|
*/ |
217
|
|
|
function getFirstDayInMonth ($y, $m) |
|
|
|
|
218
|
|
|
{ |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Returns the number of days in a week |
223
|
|
|
* |
224
|
|
|
* @param int $y year (2003) |
225
|
|
|
* @param int $m month (9) |
226
|
|
|
* @param int $d day (4) |
227
|
|
|
* |
228
|
|
|
* @return int (e.g. 7) |
229
|
|
|
* @access protected |
230
|
|
|
*/ |
231
|
|
|
function getDaysInWeek($y=null, $m=null, $d=null) |
|
|
|
|
232
|
|
|
{ |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Returns the number of the week in the year (ISO-8601), given a date |
237
|
|
|
* |
238
|
|
|
* @param int $y year (2003) |
239
|
|
|
* @param int $m month (9) |
240
|
|
|
* @param int $d day (4) |
241
|
|
|
* |
242
|
|
|
* @return int week number |
243
|
|
|
* @access protected |
244
|
|
|
*/ |
245
|
|
|
function getWeekNInYear($y, $m, $d) |
|
|
|
|
246
|
|
|
{ |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* Returns the number of the week in the month, given a date |
251
|
|
|
* |
252
|
|
|
* @param int $y year (2003) |
253
|
|
|
* @param int $m month (9) |
254
|
|
|
* @param int $d day (4) |
255
|
|
|
* @param int $firstDay first day of the week (default: 1 - monday) |
256
|
|
|
* |
257
|
|
|
* @return int week number |
258
|
|
|
* @access protected |
259
|
|
|
*/ |
260
|
|
|
function getWeekNInMonth($y, $m, $d, $firstDay=1) |
|
|
|
|
261
|
|
|
{ |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Returns the number of weeks in the month |
266
|
|
|
* |
267
|
|
|
* @param int $y year (2003) |
268
|
|
|
* @param int $m month (9) |
269
|
|
|
* |
270
|
|
|
* @return int weeks number |
271
|
|
|
* @access protected |
272
|
|
|
*/ |
273
|
|
|
function getWeeksInMonth($y, $m) |
|
|
|
|
274
|
|
|
{ |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Returns the number of the day of the week (0=sunday, 1=monday...) |
279
|
|
|
* |
280
|
|
|
* @param int $y year (2003) |
281
|
|
|
* @param int $m month (9) |
282
|
|
|
* @param int $d day (4) |
283
|
|
|
* |
284
|
|
|
* @return int weekday number |
285
|
|
|
* @access protected |
286
|
|
|
*/ |
287
|
|
|
function getDayOfWeek($y, $m, $d) |
|
|
|
|
288
|
|
|
{ |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Returns the numeric values of the days of the week. |
293
|
|
|
* |
294
|
|
|
* @param int $y year (2003) |
295
|
|
|
* @param int $m month (9) |
296
|
|
|
* @param int $d day (4) |
297
|
|
|
* |
298
|
|
|
* @return array list of numeric values of days in week, beginning 0 |
299
|
|
|
* @access protected |
300
|
|
|
*/ |
301
|
|
|
function getWeekDays($y=null, $m=null, $d=null) |
|
|
|
|
302
|
|
|
{ |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Returns the default first day of the week as an integer. Must be a |
307
|
|
|
* member of the array returned from getWeekDays |
308
|
|
|
* |
309
|
|
|
* @param int $y year (2003) |
310
|
|
|
* @param int $m month (9) |
311
|
|
|
* @param int $d day (4) |
312
|
|
|
* |
313
|
|
|
* @return int (e.g. 1 for Monday) |
314
|
|
|
* @see getWeekDays |
315
|
|
|
* @access protected |
316
|
|
|
*/ |
317
|
|
|
function getFirstDayOfWeek($y=null, $m=null, $d=null) |
|
|
|
|
318
|
|
|
{ |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* Returns the number of hours in a day |
323
|
|
|
* |
324
|
|
|
* @param int $y year (2003) |
325
|
|
|
* @param int $m month (9) |
326
|
|
|
* @param int $d day (4) |
327
|
|
|
* |
328
|
|
|
* @return int (e.g. 24) |
329
|
|
|
* @access protected |
330
|
|
|
*/ |
331
|
|
|
function getHoursInDay($y=null,$m=null,$d=null) |
|
|
|
|
332
|
|
|
{ |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* Returns the number of minutes in an hour |
337
|
|
|
* |
338
|
|
|
* @param int $y year (2003) |
339
|
|
|
* @param int $m month (9) |
340
|
|
|
* @param int $d day (4) |
341
|
|
|
* @param int $h hour |
342
|
|
|
* |
343
|
|
|
* @return int |
344
|
|
|
* @access protected |
345
|
|
|
*/ |
346
|
|
|
function getMinutesInHour($y=null,$m=null,$d=null,$h=null) |
|
|
|
|
347
|
|
|
{ |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Returns the number of seconds in a minutes |
352
|
|
|
* |
353
|
|
|
* @param int $y year (2003) |
354
|
|
|
* @param int $m month (9) |
355
|
|
|
* @param int $d day (4) |
356
|
|
|
* @param int $h hour |
357
|
|
|
* @param int $i minute |
358
|
|
|
* |
359
|
|
|
* @return int |
360
|
|
|
* @access protected |
361
|
|
|
*/ |
362
|
|
|
function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) |
|
|
|
|
363
|
|
|
{ |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
/** |
367
|
|
|
* Checks if the given day is the current day |
368
|
|
|
* |
369
|
|
|
* @param int timestamp (depending on implementation) |
|
|
|
|
370
|
|
|
* |
371
|
|
|
* @return boolean |
372
|
|
|
* @access protected |
373
|
|
|
*/ |
374
|
|
|
function isToday($stamp) |
|
|
|
|
375
|
|
|
{ |
376
|
|
|
} |
377
|
|
|
} |
378
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.