Overview

Packages

  • Date

Classes

  • Horde_Date
  • Horde_Date_Exception
  • Horde_Date_Recurrence
  • Horde_Date_Repeater
  • Horde_Date_Repeater_Day
  • Horde_Date_Repeater_DayName
  • Horde_Date_Repeater_DayPortion
  • Horde_Date_Repeater_Fortnight
  • Horde_Date_Repeater_Hour
  • Horde_Date_Repeater_Minute
  • Horde_Date_Repeater_Month
  • Horde_Date_Repeater_MonthName
  • Horde_Date_Repeater_Season
  • Horde_Date_Repeater_SeasonName
  • Horde_Date_Repeater_Second
  • Horde_Date_Repeater_Time
  • Horde_Date_Repeater_Week
  • Horde_Date_Repeater_Weekend
  • Horde_Date_Repeater_Year
  • Horde_Date_Span
  • Horde_Date_Translation
  • Horde_Date_Utils

Exceptions

  • Horde_Date_Repeater_Exception
  • Overview
  • Package
  • Class
  • Tree
 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_Day extends Horde_Date_Repeater
17: {
18:     // (24 * 60 * 60)
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: 
API documentation generated by ApiGen