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_Month extends Horde_Date_Repeater
17: {
18:     /**
19:      * 30 * 24 * 60 * 60
20:      */
21:     const MONTH_SECONDS = 2592000;
22: 
23:     public $currentMonthStart;
24: 
25:     public function next($pointer = 'future')
26:     {
27:         parent::next($pointer);
28: 
29:         if (!$this->currentMonthStart) {
30:             $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => 1));
31:         }
32:         $direction = ($pointer == 'future') ? 1 : -1;
33:         $this->currentMonthStart->month += $direction;
34: 
35:         $end = clone $this->currentMonthStart;
36:         $end->month++;
37:         return new Horde_Date_Span($this->currentMonthStart, $end);
38:     }
39: 
40:     public function this($pointer = 'future')
41:     {
42:         parent::this($pointer);
43: 
44:         switch ($pointer) {
45:         case 'future':
46:             $monthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1));
47:             $monthEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month + 1, 'day' => 1));
48:             break;
49: 
50:         case 'past':
51:             $monthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => 1));
52:             $monthEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day));
53:             break;
54: 
55:         case 'none':
56:             $monthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => 1));
57:             $monthEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month + 1, 'day' => 1));
58:             break;
59:         }
60: 
61:         return new Horde_Date_Span($monthStart, $monthEnd);
62:     }
63: 
64:     public function offset($span, $amount, $pointer)
65:     {
66:         $direction = ($pointer == 'future') ? 1 : -1;
67:         return $span->add(array('month' => $amount * $direction));
68:     }
69: 
70:     public function width()
71:     {
72:         return self::MONTH_SECONDS;
73:     }
74: 
75:     public function __toString()
76:     {
77:         return parent::__toString() . '-month';
78:     }
79: 
80: }
81: 
API documentation generated by ApiGen