1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15:
16: class Horde_Date_Repeater_Day extends Horde_Date_Repeater
17: {
18:
19: const DAY_SECONDS = 86400;
20:
21: public $currentDayStart;
22:
23: public function next($pointer = 'future')
24: {
25: parent::next($pointer);
26:
27: if (!$this->currentDayStart) {
28: $this->currentDayStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day));
29: }
30:
31: $direction = ($pointer == 'future') ? 1 : -1;
32: $this->currentDayStart->day += $direction;
33:
34: $end = clone $this->currentDayStart;
35: $end->day += 1;
36:
37: return new Horde_Date_Span($this->currentDayStart, $end);
38: }
39:
40: public function this($pointer = 'future')
41: {
42: parent::this($pointer);
43:
44: switch ($pointer) {
45: case 'future':
46: $dayBegin = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour + 1));
47: $dayEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1));
48: break;
49:
50: case 'past':
51: $dayBegin = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day));
52: $dayEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour));
53: break;
54:
55: case 'none':
56: $dayBegin = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day));
57: $dayEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1));
58: break;
59: }
60:
61: return new Horde_Date_Span($dayBegin, $dayEnd);
62: }
63:
64: public function offset($span, $amount, $pointer)
65: {
66: $direction = ($pointer == 'future') ? 1 : -1;
67: return $span->add(array('day' => $direction * $amount));
68: }
69:
70: public function width()
71: {
72: return self::DAY_SECONDS;
73: }
74:
75: public function __toString()
76: {
77: return parent::__toString() . '-day';
78: }
79:
80: }
81: