1: <?php
2: /**
3: * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (LGPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
7: *
8: * @category Horde
9: * @package Date
10: */
11:
12: /**
13: * @category Horde
14: * @package Date
15: */
16: class Horde_Date_Repeater_Second extends Horde_Date_Repeater
17: {
18: public $secondStart;
19:
20: public function next($pointer = 'future')
21: {
22: parent::next($pointer);
23:
24: $direction = ($pointer == 'future') ? 1 : -1;
25:
26: if (!$this->secondStart) {
27: $this->secondStart = clone $this->now;
28: $this->secondStart->sec += $direction;
29: } else {
30: $this->secondStart += $direction;
31: }
32:
33: $end = clone $this->secondStart;
34: $end->sec++;
35: return new Horde_Date_Span($this->secondStart, $end);
36: }
37:
38: public function this($pointer = 'future')
39: {
40: parent::this($pointer);
41:
42: $end = clone $this->now;
43: $end->sec++;
44: return new Horde_Date_Span($this->now, $end);
45: }
46:
47: public function offset($span, $amount, $pointer)
48: {
49: $direction = ($pointer == 'future') ? 1 : -1;
50: return $span->add($direction * $amount);
51: }
52:
53: public function width()
54: {
55: return 1;
56: }
57:
58: public function __toString()
59: {
60: return parent::__toString() . '-second';
61: }
62:
63: }
64: