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_Fortnight extends Horde_Date_Repeater
17: {
18:     // (14 * 24 * 60 * 60)
19:     const FORTNIGHT_SECONDS = 1209600;
20: 
21:     public $currentFortnightStart;
22: 
23:     public function next($pointer = 'future')
24:     {
25:         parent::next($pointer);
26: 
27:         if (!$this->currentFortnightStart) {
28:             switch ($pointer) {
29:             case 'future':
30:                 $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
31:                 $sundayRepeater->now = $this->now;
32:                 $nextSundaySpan = $sundayRepeater->next('future');
33:                 $this->currentFortnightStart = $nextSundaySpan->begin;
34:                 break;
35: 
36:             case 'past':
37:                 $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
38:                 $sundayRepeater->now = clone $this->now;
39:                 $sundayRepeater->now->day++;
40:                 $sundayRepeater->next('past');
41:                 $sundayRepeater->next('past');
42:                 $lastSundaySpan = $sundayRepeater->next('past');
43:                 $this->currentFortnightStart = $lastSundaySpan->begin;
44:                 break;
45:             }
46:         } else {
47:             $direction = ($pointer == 'future') ? 1 : -1;
48:             $this->currentFortnightStart->add($direction * self::FORTNIGHT_SECONDS);
49:         }
50: 
51:         return new Horde_Date_Span($this->currentFortnightStart, $this->currentFortnightStart->add(self::FORTNIGHT_SECONDS));
52:     }
53: 
54:     public function this($pointer = 'future')
55:     {
56:         parent::this($pointer);
57: 
58:         switch ($pointer) {
59:         case 'future':
60:         case 'none':
61:             $thisFortnightStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour + 1));
62:             $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
63:             $sundayRepeater->now = $this->now;
64:             $sundayRepeater->this('future');
65:             $thisSundaySpan = $sundayRepeater->this('future');
66:             $thisFortnightEnd = $thisSundaySpan->begin;
67:             return new Horde_Date_Span($thisFortnightStart, $thisFortnightEnd);
68: 
69:         case 'past':
70:             $thisFortnightEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour));
71:             $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
72:             $sundayRepeater->now = $this->now;
73:             $lastSundaySpan = $sundayRepeater->next('past');
74:             $thisFortnightStart = $lastSundaySpan->begin;
75:             return new Horde_Date_Span($thisFortnightStart, $thisFortnightEnd);
76:         }
77:     }
78: 
79:     public function offset($span, $amount, $pointer)
80:     {
81:         $direction = ($pointer == 'future') ? 1 : -1;
82:         return $span->add($direction * $amount * self::FORTNIGHT_SECONDS);
83:     }
84: 
85:     public function width()
86:     {
87:         return self::FORTNIGHT_SECONDS;
88:     }
89: 
90:     public function __toString()
91:     {
92:         return parent::__toString() . '-fortnight';
93:     }
94: 
95: }
96: 
API documentation generated by ApiGen