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