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