/usr/share/php/Horde/Date/Repeater/MonthName.php is in php-horde-date 2.4.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | <?php
/**
* Copyright 2009-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @package Date
*/
/**
* Date repeater.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @category Horde
* @copyright 2009-2017 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @package Date
*/
class Horde_Date_Repeater_MonthName extends Horde_Date_Repeater
{
public $currentMonthStart;
public $type;
public function __construct($type)
{
$this->type = $type;
}
public function next($pointer = 'future')
{
parent::next($pointer);
if (!$this->currentMonthStart) {
$targetMonth = $this->_monthNumber($this->type);
switch ($pointer) {
case 'future':
if ($this->now->month < $targetMonth) {
$this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $targetMonth, 'day' => 1));
} else {
$this->currentMonthStart = new Horde_Date(array('year' => $this->now->year + 1, 'month' => $targetMonth, 'day' => 1));
}
break;
case 'none':
if ($this->now->month <= $targetMonth) {
$this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $targetMonth, 'day' => 1));
} else {
$this->currentMonthStart = new Horde_Date(array('year' => $this->now->year + 1, 'month' => $targetMonth, 'day' => 1));
}
break;
case 'past':
if ($this->now->month > $targetMonth) {
$this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $targetMonth, 'day' => 1));
} else {
$this->currentMonthStart = new Horde_Date(array('year' => $this->now->year - 1, 'month' => $targetMonth, 'day' => 1));
}
break;
}
} else {
switch ($pointer) {
case 'future':
$this->currentMonthStart->year++;
break;
case 'past':
$this->currentMonthStart->year--;
break;
}
}
return new Horde_Date_Span($this->currentMonthStart, $this->currentMonthStart->add(array('month' => 1)));
}
public function this($pointer = 'future')
{
parent::this($pointer);
switch ($pointer) {
case 'past':
return $this->next($pointer);
case 'future':
case 'none':
return $this->next('none');
}
}
public function width()
{
return Horde_Date_Repeater_Month::MONTH_SECONDS;
}
public function index()
{
return $this->_monthNumber($this->type);
}
public function __toString()
{
return parent::__toString() . '-monthname-' . $this->type;
}
protected function _monthNumber($monthName)
{
$months = array(
'january' => 1,
'february' => 2,
'march' => 3,
'april' => 4,
'may' => 5,
'june' => 6,
'july' => 7,
'august' => 8,
'september' => 9,
'october' => 10,
'november' => 11,
'december' => 12,
);
if (!isset($months[$monthName])) {
throw new InvalidArgumentException('Invalid month name "' . $monthName . '"');
}
return $months[$monthName];
}
}
|