From bba1ebec3e6a046f5ebc583b84ab3c9112555266 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Fri, 29 May 2009 18:22:17 -0400 Subject: [PATCH] moving Horde_Date_Repeater and Horde_Date_Span to the horde/date package --- framework/Date_Parser/lib/Horde/Date/Repeater.php | 46 ------- .../Date_Parser/lib/Horde/Date/Repeater/Day.php | 66 ---------- .../lib/Horde/Date/Repeater/DayName.php | 74 ----------- .../lib/Horde/Date/Repeater/DayPortion.php | 146 --------------------- .../lib/Horde/Date/Repeater/Exception.php | 4 - .../lib/Horde/Date/Repeater/Fortnight.php | 81 ------------ .../Date_Parser/lib/Horde/Date/Repeater/Hour.php | 61 --------- .../Date_Parser/lib/Horde/Date/Repeater/Minute.php | 61 --------- .../Date_Parser/lib/Horde/Date/Repeater/Month.php | 66 ---------- .../lib/Horde/Date/Repeater/MonthName.php | 109 --------------- .../Date_Parser/lib/Horde/Date/Repeater/Season.php | 31 ----- .../lib/Horde/Date/Repeater/SeasonName.php | 42 ------ .../Date_Parser/lib/Horde/Date/Repeater/Second.php | 49 ------- .../Date_Parser/lib/Horde/Date/Repeater/Time.php | 136 ------------------- .../Date_Parser/lib/Horde/Date/Repeater/Week.php | 89 ------------- .../lib/Horde/Date/Repeater/Weekend.php | 80 ----------- .../Date_Parser/lib/Horde/Date/Repeater/Year.php | 60 --------- framework/Date_Parser/lib/Horde/Date/Span.php | 77 ----------- framework/Date_Parser/test/Horde/Date/AllTests.php | 54 -------- framework/Date_Parser/test/Horde/Date/DateTest.php | 47 ------- .../test/Horde/Date/Repeater/DayNameTest.php | 48 ------- .../test/Horde/Date/Repeater/DayTest.php | 29 ---- .../test/Horde/Date/Repeater/HourTest.php | 76 ----------- .../test/Horde/Date/Repeater/MonthNameTest.php | 67 ---------- .../test/Horde/Date/Repeater/MonthTest.php | 40 ------ .../test/Horde/Date/Repeater/TimeTest.php | 81 ------------ .../test/Horde/Date/Repeater/WeekTest.php | 78 ----------- .../test/Horde/Date/Repeater/WeekendTest.php | 88 ------------- .../test/Horde/Date/Repeater/YearTest.php | 76 ----------- framework/Date_Parser/test/Horde/Date/SpanTest.php | 38 ------ 30 files changed, 2000 deletions(-) delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Day.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/DayName.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/DayPortion.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Exception.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Fortnight.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Hour.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Minute.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Month.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/MonthName.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Season.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/SeasonName.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Second.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Time.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Week.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Weekend.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Repeater/Year.php delete mode 100644 framework/Date_Parser/lib/Horde/Date/Span.php delete mode 100644 framework/Date_Parser/test/Horde/Date/AllTests.php delete mode 100644 framework/Date_Parser/test/Horde/Date/DateTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/DayNameTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/DayTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/HourTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/MonthNameTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/MonthTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/TimeTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/WeekTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/WeekendTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/Repeater/YearTest.php delete mode 100644 framework/Date_Parser/test/Horde/Date/SpanTest.php diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater.php b/framework/Date_Parser/lib/Horde/Date/Repeater.php deleted file mode 100644 index 5fdd9641b..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater.php +++ /dev/null @@ -1,46 +0,0 @@ -now)) { - throw new Horde_Date_Repeater_Exception('Start point must be set before calling next()'); - } - - if (!in_array($pointer, array('future', 'none', 'past'))) { - throw new Horde_Date_Repeater_Exception("First argument 'pointer' must be one of 'past', 'future', 'none'"); - } - } - - public function this($pointer) - { - if (is_null($this->now)) { - throw new Horde_Date_Repeater_Exception('Start point must be set before calling this()'); - } - - if (!in_array($pointer, array('future', 'none', 'past'))) { - throw new Horde_Date_Repeater_Exception("First argument 'pointer' must be one of 'past', 'future', 'none'"); - } - } - - public function __toString() - { - return 'repeater'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Day.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Day.php deleted file mode 100644 index 7cc544b02..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Day.php +++ /dev/null @@ -1,66 +0,0 @@ -currentDayStart) { - $this->currentDayStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day)); - } - - $direction = ($pointer == 'future') ? 1 : -1; - $this->currentDayStart->day += $direction; - - $end = clone $this->currentDayStart; - $end->day += 1; - - return new Horde_Date_Span($this->currentDayStart, $end); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - $dayBegin = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour + 1)); - $dayEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1)); - break; - - case 'past': - $dayBegin = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day)); - $dayEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour)); - break; - - case 'none': - $dayBegin = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day)); - $dayEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1)); - break; - } - - return new Horde_Date_Span($dayBegin, $dayEnd); - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add(array('day' => $direction * $amount)); - } - - public function width() - { - return self::DAY_SECONDS; - } - - public function __toString() - { - return parent::__toString() . '-day'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/DayName.php b/framework/Date_Parser/lib/Horde/Date/Repeater/DayName.php deleted file mode 100644 index 578b96680..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/DayName.php +++ /dev/null @@ -1,74 +0,0 @@ -type = $type; - } - - public function next($pointer) - { - parent::next($pointer); - - $direction = ($pointer == 'future') ? 1 : -1; - - if (!$this->currentDayStart) { - $this->currentDayStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + $direction)); - - $dayNum = $this->_dayNumber($this->type); - while ($this->currentDayStart->dayOfWeek() != $dayNum) { - $this->currentDayStart->day += $direction; - } - } else { - $this->currentDayStart->day += $direction * 7; - } - - $end = clone $this->currentDayStart; - $end->day++; - return new Horde_Date_Span($this->currentDayStart, $end); - } - - public function this($pointer = 'future') - { - parent::next($pointer); - - if ($pointer == 'none') { - $pointer = 'future'; - } - return $this->next($pointer); - } - - public function width() - { - return self::DAY_SECONDS; - } - - public function __toString() - { - return parent::__toString() . '-dayname-' . $this->type; - } - - protected function _dayNumber($dayName) - { - $days = array( - 'monday' => Horde_Date::DATE_MONDAY, - 'tuesday' => Horde_Date::DATE_TUESDAY, - 'wednesday' => Horde_Date::DATE_WEDNESDAY, - 'thursday' => Horde_Date::DATE_THURSDAY, - 'friday' => Horde_Date::DATE_FRIDAY, - 'saturday' => Horde_Date::DATE_SATURDAY, - 'sunday' => Horde_Date::DATE_SUNDAY, - ); - if (!isset($days[$dayName])) { - throw new InvalidArgumentException('Invalid day name "' . $dayName . '"'); - } - return $days[$dayName]; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/DayPortion.php b/framework/Date_Parser/lib/Horde/Date/Repeater/DayPortion.php deleted file mode 100644 index ee63cc241..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/DayPortion.php +++ /dev/null @@ -1,146 +0,0 @@ -type = $type; - - if (is_int($type)) { - $this->range = array(($type * 3600), (($type + 12) * 3600)); - } else { - $lookup = array( - 'am' => array(0, (12 * 3600 - 1)), - 'pm' => array((12 * 3600), (24 * 3600 - 1)), - 'morning' => self::$morning, - 'afternoon' => self::$afternoon, - 'evening' => self::$evening, - 'night' => self::$night, - ); - if (!isset($lookup[$type])) { - throw new InvalidArgumentException("Invalid type '$type' for Repeater_DayPortion"); - } - $this->range = $lookup[$type]; - } - } - - public function next($pointer) - { - parent::next($pointer); - - $fullDay = 60 * 60 * 24; - - if (!$this->currentSpan) { - $nowSeconds = $this->now->hour * 3600 + $this->now->min * 60 + $this->now->sec; - if ($nowSeconds < $this->range[0]) { - switch ($pointer) { - case 'future': - $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'sec' => $this->range[0])); - break; - - case 'past': - $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day - 1, 'sec' => $this->range[0])); - break; - } - } elseif ($nowSeconds > $this->range[1]) { - switch ($pointer) { - case 'future': - $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1, 'sec' => $this->range[0])); - break; - - case 'past': - $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'sec' => $this->range[0])); - break; - } - } else { - switch ($pointer) { - case 'future': - $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1, 'sec' => $this->range[0])); - break; - - case 'past': - $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day - 1, 'sec' => $this->range[0])); - break; - } - } - - $rangeEnd = $rangeStart->add($this->range[1] - $this->range[0]); - $this->currentSpan = new Horde_Date_Span($rangeStart, $rangeEnd); - } else { - switch ($pointer) { - case 'future': - $this->currentSpan = $this->currentSpan->add(array('day' => 1)); - break; - - case 'past': - $this->currentSpan = $this->currentSpan->add(array('day' => -1)); - break; - } - } - - return $this->currentSpan; - } - - public function this($context = 'future') - { - parent::this($context); - - $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'sec' => $this->range[0])); - $this->currentSpan = new Horde_Date_Span($rangeStart, $rangeStart->add($this->range[1] - $this->range[0])); - return $this->currentSpan; - } - - public function offset($span, $amount, $pointer) - { - $this->now = $span->begin; - $portionSpan = $this->next($pointer); - $direction = ($pointer == 'future') ? 1 : -1; - return $portionSpan->add(array('day' => $direction * ($amount - 1))); - } - - public function width() - { - if (!$this->range) { - throw new Horde_Date_Repeater_Exception('Range has not been set'); - } - - if ($this->currentSpan) { - return $this->currentSpan->width(); - } - - if (is_int($this->type)) { - return (12 * 3600); - } else { - return $this->range[1] - $this->range[0]; - } - } - - public function __toString() - { - return parent::__toString() . '-dayportion-' . $this->type; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Exception.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Exception.php deleted file mode 100644 index 0fb573e7a..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Exception.php +++ /dev/null @@ -1,4 +0,0 @@ -currentFortnightStart) { - switch ($pointer) { - case 'future': - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = $this->now; - $nextSundaySpan = $sundayRepeater->next('future'); - $this->currentFortnightStart = $nextSundaySpan->begin; - break; - - case 'past': - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = clone $this->now; - $sundayRepeater->now->day++; - $sundayRepeater->next('past'); - $sundayRepeater->next('past'); - $lastSundaySpan = $sundayRepeater->next('past'); - $this->currentFortnightStart = $lastSundaySpan->begin; - break; - } - } else { - $direction = ($pointer == 'future') ? 1 : -1; - $this->currentFortnightStart->add($direction * self::FORTNIGHT_SECONDS); - } - - return new Horde_Date_Span($this->currentFortnightStart, $this->currentFortnightStart->add(self::FORTNIGHT_SECONDS)); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - case 'none': - $thisFortnightStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour + 1)); - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = $this->now; - $sundayRepeater->this('future'); - $thisSundaySpan = $sundayRepeater->this('future'); - $thisFortnightEnd = $thisSundaySpan->begin; - return new Horde_Date_Span($thisFortnightStart, $thisFortnightEnd); - - case 'past': - $thisFortnightEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour)); - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = $this->now; - $lastSundaySpan = $sundayRepeater->next('past'); - $thisFortnightStart = $lastSundaySpan->begin; - return new Horde_Date_Span($thisFortnightStart, $thisFortnightEnd); - } - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add($direction * $amount * self::FORTNIGHT_SECONDS); - } - - public function width() - { - return self::FORTNIGHT_SECONDS; - } - - public function __toString() - { - return parent::__toString() . '-fortnight'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Hour.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Hour.php deleted file mode 100644 index 31b30b2f9..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Hour.php +++ /dev/null @@ -1,61 +0,0 @@ -currentHourStart) { - $this->currentHourStart = new Horde_Date(array('month' => $this->now->month, 'year' => $this->now->year, 'day' => $this->now->day, 'hour' => $this->now->hour)); - } - $this->currentHourStart->hour += $direction; - - $end = clone $this->currentHourStart; - $end->hour++; - return new Horde_Date_Span($this->currentHourStart, $end); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - $hourStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min + 1)); - $hourEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour + 1)); - break; - - case 'past': - $hourStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour)); - $hourEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min)); - break; - - case 'none': - $hourStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour)); - $hourEnd = $hourStart->add(array('hour' => 1)); - break; - } - - return new Horde_Date_Span($hourStart, $hourEnd); - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add(array('hour' => $direction * $amount)); - } - - public function width() - { - return 3600; - } - - public function __toString() - { - return parent::__toString() . '-hour'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Minute.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Minute.php deleted file mode 100644 index 0f5ff0ac5..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Minute.php +++ /dev/null @@ -1,61 +0,0 @@ -currentMinuteStart) { - $this->currentMinuteStart = new Horde_Date(array('month' => $this->now->month, 'year' => $this->now->year, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min)); - } - $direction = ($pointer == 'future') ? 1 : -1; - $this->currentMinuteStart->min += $direction; - - $end = clone $this->currentMinuteStart; - $end->min++; - return new Horde_Date_Span($this->currentMinuteStart, $end); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - $minuteBegin = clone $this->now; - $minuteEnd = new Horde_Date(array('month' => $this->now->month, 'year' => $this->now->year, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min)); - break; - - case 'past': - $minuteBegin = new Horde_Date(array('month' => $this->now->month, 'year' => $this->now->year, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min)); - $minuteEnd = clone $this->now; - break; - - case 'none': - $minuteBegin = new Horde_Date(array('month' => $this->now->month, 'year' => $this->now->year, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min)); - $minuteEnd = new Horde_Date(array('month' => $this->now->month, 'year' => $this->now->year, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min + 1)); - break; - } - - return new Horde_Date_Span($minuteBegin, $minuteEnd); - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add(array('min' => $direction * $amount)); - } - - public function width() - { - return 60; - } - - public function __toString() - { - return parent::__toString() . '-minute'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Month.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Month.php deleted file mode 100644 index 9afba94e1..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Month.php +++ /dev/null @@ -1,66 +0,0 @@ -currentMonthStart) { - $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => 1)); - } - $direction = ($pointer == 'future') ? 1 : -1; - $this->currentMonthStart->month += $direction; - - $end = clone $this->currentMonthStart; - $end->month++; - return new Horde_Date_Span($this->currentMonthStart, $end); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - $monthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1)); - $monthEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month + 1, 'day' => 1)); - break; - - case 'past': - $monthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => 1)); - $monthEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day)); - break; - - case 'none': - $monthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => 1)); - $monthEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month + 1, 'day' => 1)); - break; - } - - return new Horde_Date_Span($monthStart, $monthEnd); - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add(array('month' => $amount * $direction)); - } - - public function width() - { - return self::MONTH_SECONDS; - } - - public function __toString() - { - return parent::__toString() . '-month'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/MonthName.php b/framework/Date_Parser/lib/Horde/Date/Repeater/MonthName.php deleted file mode 100644 index d7b355e9b..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/MonthName.php +++ /dev/null @@ -1,109 +0,0 @@ -type = $type; - } - - public function next($pointer) - { - 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]; - } - -} \ No newline at end of file diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Season.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Season.php deleted file mode 100644 index 2ad200b95..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Season.php +++ /dev/null @@ -1,31 +0,0 @@ -type = $type; - } - - public function next($pointer) - { - parent::next($pointer); - throw new Horde_Date_Repeater_Exception('Not implemented'); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - throw new Horde_Date_Repeater_Exception('Not implemented'); - } - - public function width() - { - return self::SEASON_SECONDS; - } - - public function __toString() - { - return parent::__toString() . '-season-' . $this->type; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Second.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Second.php deleted file mode 100644 index 1e16b7ed6..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Second.php +++ /dev/null @@ -1,49 +0,0 @@ -secondStart) { - $this->secondStart = clone $this->now; - $this->secondStart->sec += $direction; - } else { - $this->secondStart += $direction; - } - - $end = clone $this->secondStart; - $end->sec++; - return new Horde_Date_Span($this->secondStart, $end); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - $end = clone $this->now; - $end->sec++; - return new Horde_Date_Span($this->now, $end); - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add($direction * $amount); - } - - public function width() - { - return 1; - } - - public function __toString() - { - return parent::__toString() . '-second'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Time.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Time.php deleted file mode 100644 index 405cd66c8..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Time.php +++ /dev/null @@ -1,136 +0,0 @@ -ambiguous = true; - $this->type = ($hours == 12) ? 0 : $hours * 3600; - break; - - case 3: - $this->ambiguous = true; - $this->type = $t[0] * 3600 + (int)substr($t, 1, 2) * 60; - break; - - case 4: - $this->ambiguous = (strpos($time, ':') !== false) && ($t[0] != 0) && ((int)substr($t, 0, 2) <= 12); - $hours = (int)substr($t, 0, 2); - $this->type = ($hours == 12) ? - ((int)substr($t, 2, 2) * 60) : - ($hours * 60 * 60 + (int)substr($t, 2, 2) * 60); - break; - - case 5: - $this->ambiguous = true; - $this->type = $t[0] * 3600 + (int)substr($t, 1, 2) * 60 + (int)substr($t, 3, 2); - break; - - case 6: - $this->ambiguous = (strpos($time, ':') !== false) && ($t[0] != 0) && ((int)substr($t, 0, 2) <= 12); - $hours = (int)substr($t, 0, 2); - $this->type = ($hours == 12) ? - ((int)substr($t, 2, 2) * 60 + (int)substr($t, 4, 2)) : - ($hours * 60 * 60 + (int)substr($t, 2, 2) * 60 + (int)substr($t, 4, 2)); - break; - - default: - throw new Horde_Date_Repeater_Exception('Time cannot exceed six digits'); - } - } - - /** - * Return the next past or future Span for the time that this Repeater represents - * pointer - Symbol representing which temporal direction to fetch the next day - * must be either :past or :future - */ - public function next($pointer) - { - parent::next($pointer); - - $halfDay = 3600 * 12; - $fullDay = 3600 * 24; - - $first = false; - - if (!$this->currentTime) { - $first = true; - $midnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day)); - $yesterdayMidnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day - 1)); - $tomorrowMidnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1)); - - if ($pointer == 'future') { - if ($this->ambiguous) { - foreach (array($midnight->add($this->type), $midnight->add($halfDay + $this->type), $tomorrowMidnight->add($this->type)) as $t) { - if ($t->compareDateTime($this->now) >= 0) { - $this->currentTime = $t; - break; - } - } - } else { - foreach (array($midnight->add($this->type), $tomorrowMidnight->add($this->type)) as $t) { - if ($t->compareDateTime($this->now) >= 0) { - $this->currentTime = $t; - break; - } - } - } - } elseif ($pointer == 'past') { - if ($this->ambiguous) { - foreach (array($midnight->add($halfDay + $this->type), $midnight->add($this->type), $yesterdayMidnight->add($this->type * 2)) as $t) { - if ($t->compareDateTime($this->now) <= 0) { - $this->currentTime = $t; - break; - } - } - } else { - foreach (array($midnight->add($this->type), $yesterdayMidnight->add($this->type)) as $t) { - if ($t->compareDateTime($this->now) <= 0) { - $this->currentTime = $t; - break; - } - } - } - } - - if (!$this->currentTime) { - throw new Horde_Date_Repeater_Exception('Current time cannot be null at this point'); - } - } - - if (!$first) { - $increment = $this->ambiguous ? $halfDay : $fullDay; - $this->currentTime->sec += ($pointer == 'future') ? $increment : -$increment; - } - - return new Horde_Date_Span($this->currentTime, $this->currentTime->add(1)); - } - - public function this($context = 'future') - { - parent::this($context); - - if ($context == 'none') { $context = 'future'; } - return $this->next($context); - } - - public function width() - { - return 1; - } - - public function __toString() - { - return parent::__toString() . '-time-' . $this->type; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Week.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Week.php deleted file mode 100644 index ff16a6eb2..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Week.php +++ /dev/null @@ -1,89 +0,0 @@ -currentWeekStart) { - switch ($pointer) { - case 'future': - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = $this->now; - $nextSundaySpan = $sundayRepeater->next('future'); - $this->currentWeekStart = $nextSundaySpan->begin; - break; - - case 'past': - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = clone $this->now; - $sundayRepeater->now->day++; - $sundayRepeater->next('past'); - $lastSundaySpan = $sundayRepeater->next('past'); - $this->currentWeekStart = $lastSundaySpan->begin; - break; - } - } else { - $direction = ($pointer == 'future') ? 1 : -1; - $this->currentWeekStart->day += $direction * 7; - } - - return new Horde_Date_Span($this->currentWeekStart, $this->currentWeekStart->add(array('day' => 7))); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - $thisWeekStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour + 1)); - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = $this->now; - $thisSundaySpan = $sundayRepeater->this('future'); - $thisWeekEnd = $thisSundaySpan->begin; - return new Horde_Date_Span($thisWeekStart, $thisWeekEnd); - - case 'past': - $thisWeekEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour)); - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = $this->now; - $lastSundaySpan = $sundayRepeater->next('past'); - $thisWeekStart = $lastSundaySpan->begin; - return new Horde_Date_Span($thisWeekStart, $thisWeekEnd); - - case 'none': - $sundayRepeater = new Horde_Date_Repeater_DayName('sunday'); - $sundayRepeater->now = $this->now; - $lastSundaySpan = $sundayRepeater->next('past'); - $thisWeekStart = $lastSundaySpan->begin; - $thisWeekEnd = clone $thisWeekStart; - $thisWeekEnd->day += 7; - return new Horde_Date_Span($thisWeekStart, $thisWeekEnd); - } - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add(array('day' => $direction * $amount * 7)); - } - - public function width() - { - return self::WEEK_SECONDS; - } - - public function __toString() - { - return parent::__toString() . '-week'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Weekend.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Weekend.php deleted file mode 100644 index 0116f97b9..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Weekend.php +++ /dev/null @@ -1,80 +0,0 @@ -currentWeekStart) { - switch ($pointer) { - case 'future': - $saturdayRepeater = new Horde_Date_Repeater_DayName('saturday'); - $saturdayRepeater->now = $this->now; - $nextSaturdaySpan = $saturdayRepeater->next('future'); - $this->currentWeekStart = $nextSaturdaySpan->begin; - break; - - case 'past': - $saturdayRepeater = new Horde_Date_Repeater_DayName('saturday'); - $saturdayRepeater->now = $this->now; - $saturdayRepeater->now->day++; - $lastSaturdaySpan = $saturdayRepeater->next('past'); - $this->currentWeekStart = $lastSaturdaySpan->begin; - break; - } - } else { - $direction = ($pointer == 'future') ? 1 : -1; - $this->currentWeekStart->day += $direction * 7; - } - - return new Horde_Date_Span($this->currentWeekStart, $this->currentWeekStart->add(array('day' => 2))); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - case 'none': - $saturdayRepeater = new Horde_Date_Repeater_DayName('saturday'); - $saturdayRepeater->now = $this->now; - $thisSaturdaySpan = $saturdayRepeater->this('future'); - return new Horde_Date_Span($thisSaturdaySpan->begin, $thisSaturdaySpan->begin->add(array('day' => 2))); - - case 'past': - $saturdayRepeater = new Horde_Date_Repeater_DayName('saturday'); - $saturdayRepeater->now = $this->now; - $lastSaturdaySpan = $saturdayRepeater->this('past'); - return new Horde_Date_Span($lastSaturdaySpan->begin, $lastSaturdaySpan->begin->add(array('day' => 2))); - } - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - $weekend = new self(); - $weekend->now = clone $span->begin; - $start = $weekend->next($pointer)->begin; - $start->day += ($amount - 1) * $direction * 7; - return new Horde_Date_Span($start, $start->add($span->width())); - } - - public function width() - { - return self::WEEKEND_SECONDS; - } - - public function __toString() - { - return parent::__toString() . '-weekend'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Repeater/Year.php b/framework/Date_Parser/lib/Horde/Date/Repeater/Year.php deleted file mode 100644 index e31207d96..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Repeater/Year.php +++ /dev/null @@ -1,60 +0,0 @@ -currentYearStart) { - $this->currentYearStart = new Horde_Date(array('year' => $this->now->year, 'month' => 1, 'day' => 1)); - } - - $diff = ($pointer == 'future') ? 1 : -1; - $this->currentYearStart->year += $diff; - - return new Horde_Date_Span($this->currentYearStart, $this->currentYearStart->add(array('year' => 1))); - } - - public function this($pointer = 'future') - { - parent::this($pointer); - - switch ($pointer) { - case 'future': - $thisYearStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1)); - $thisYearEnd = new Horde_Date(array('year' => $this->now->year + 1, 'month' => 1, 'day' => 1)); - break; - - case 'past': - $thisYearStart = new Horde_Date(array('year' => $this->now->year, 'month' => 1, 'day' => 1)); - $thisYearEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day)); - break; - - case 'none': - $thisYearStart = new Horde_Date(array('year' => $this->now->year, 'month' => 1, 'day' => 1)); - $thisYearEnd = new Horde_Date(array('year' => $this->now->year + 1, 'month' => 1, 'day' => 1)); - break; - } - - return new Horde_Date_Span($thisYearStart, $thisYearEnd); - } - - public function offset($span, $amount, $pointer) - { - $direction = ($pointer == 'future') ? 1 : -1; - return $span->add(array('year' => ($amount * $direction))); - } - - public function width() - { - return (365 * 24 * 60 * 60); - } - - public function __toString() - { - return parent::__toString() . '-year'; - } - -} diff --git a/framework/Date_Parser/lib/Horde/Date/Span.php b/framework/Date_Parser/lib/Horde/Date/Span.php deleted file mode 100644 index ad5900c82..000000000 --- a/framework/Date_Parser/lib/Horde/Date/Span.php +++ /dev/null @@ -1,77 +0,0 @@ -begin = $begin; - $this->end = $end; - } - - /** - * Return the width of this span in seconds - */ - public function width() - { - return abs($this->end->timestamp() - $this->begin->timestamp()); - } - - /** - * Is a Horde_Date within this span? - * - * @param Horde_Date $date - */ - public function includes($date) - { - return ($this->begin->compareDateTime($date) <= 0) && ($this->end->compareDateTime($date) >= 0); - } - - /** - * Add a number of seconds to this span, returning the new span - */ - public function add($factor) - { - return new Horde_Date_Span($this->begin->add($factor), $this->end->add($factor)); - } - - /** - * Subtract a number of seconds from this span, returning the new span. - */ - public function sub($factor) - { - return new Horde_Date_Span($this->begin->sub($factor), $this->end->sub($factor)); - } - - public function __toString() - { - return '(' . $this->begin . '..' . $this->end . ')'; - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/AllTests.php b/framework/Date_Parser/test/Horde/Date/AllTests.php deleted file mode 100644 index c68efa643..000000000 --- a/framework/Date_Parser/test/Horde/Date/AllTests.php +++ /dev/null @@ -1,54 +0,0 @@ -isFile() && preg_match('/Test.php$/', $file->getFilename())) { - $pathname = $file->getPathname(); - require $pathname; - - $class = str_replace(DIRECTORY_SEPARATOR, '_', - preg_replace("/^$baseregexp(.*)\.php/", '\\1', $pathname)); - $suite->addTestSuite('Horde_Date_' . $class); - } - } - - return $suite; - } - -} - -if (PHPUnit_MAIN_METHOD == 'Horde_Date_AllTests::main') { - Horde_Date_AllTests::main(); -} diff --git a/framework/Date_Parser/test/Horde/Date/DateTest.php b/framework/Date_Parser/test/Horde/Date/DateTest.php deleted file mode 100644 index 2f5b0b4dd..000000000 --- a/framework/Date_Parser/test/Horde/Date/DateTest.php +++ /dev/null @@ -1,47 +0,0 @@ -month -= 2; - $this->assertEquals(2007, $d->year); - - $d = new Horde_Date('2008-01-01 00:00:00'); - $d->day -= 1; - $this->assertEquals(2007, $d->year); - $this->assertEquals(12, $d->month); - - $d = new Horde_Date('2008-01-01 00:00:00'); - $d->day += 370; - $this->assertEquals(2009, $d->year); - $this->assertEquals(1, $d->month); - - $d = new Horde_Date('2008-01-01 00:00:00'); - $d->sec += 14400; - $this->assertEquals(0, $d->sec); - $this->assertEquals(0, $d->min); - $this->assertEquals(4, $d->hour); - } - - public function testDateMath() - { - $d = new Horde_Date('2008-01-01 00:00:00'); - - $this->assertEquals('2007-12-31 00:00:00', (string)$d->sub(array('day' => 1))); - $this->assertEquals('2009-01-01 00:00:00', (string)$d->add(array('year' => 1))); - $this->assertEquals('2008-01-01 04:00:00', (string)$d->add(14400)); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/DayNameTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/DayNameTest.php deleted file mode 100644 index 21231eaf8..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/DayNameTest.php +++ /dev/null @@ -1,48 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testNextFuture() - { - $mondays = new Horde_Date_Repeater_DayName('monday'); - $mondays->now = $this->now; - - $span = $mondays->next('future'); - $this->assertEquals('2006-08-21', $span->begin->format('Y-m-d')); - $this->assertEquals('2006-08-22', $span->end->format('Y-m-d')); - - $span = $mondays->next('future'); - $this->assertEquals('2006-08-28', $span->begin->format('Y-m-d')); - $this->assertEquals('2006-08-29', $span->end->format('Y-m-d')); - } - - public function testNextPast() - { - $mondays = new Horde_Date_Repeater_DayName('monday'); - $mondays->now = $this->now; - - $span = $mondays->next('past'); - $this->assertEquals('2006-08-14', $span->begin->format('Y-m-d')); - $this->assertEquals('2006-08-15', $span->end->format('Y-m-d')); - - $span = $mondays->next('past'); - $this->assertEquals('2006-08-07', $span->begin->format('Y-m-d')); - $this->assertEquals('2006-08-08', $span->end->format('Y-m-d')); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/DayTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/DayTest.php deleted file mode 100644 index ffbcedec4..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/DayTest.php +++ /dev/null @@ -1,29 +0,0 @@ -now = new Horde_Date('2009-01-01'); - $this->assertEquals('(2009-01-02 00:00:00..2009-01-03 00:00:00)', (string)$repeater->next('future')); - } - - public function testNextPast() - { - $repeater = new Horde_Date_Repeater_Day(); - $repeater->now = new Horde_Date('2009-01-01'); - $this->assertEquals('(2008-12-31 00:00:00..2009-01-01 00:00:00)', (string)$repeater->next('past')); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/HourTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/HourTest.php deleted file mode 100644 index aed7910ea..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/HourTest.php +++ /dev/null @@ -1,76 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testNextFuture() - { - $hours = new Horde_Date_Repeater_Hour(); - $hours->now = $this->now; - - $nextHour = $hours->next('future'); - $this->assertEquals('2006-08-16 15:00:00', (string)$nextHour->begin); - $this->assertEquals('2006-08-16 16:00:00', (string)$nextHour->end); - - $nextNextHour = $hours->next('future'); - $this->assertEquals('2006-08-16 16:00:00', (string)$nextNextHour->begin); - $this->assertEquals('2006-08-16 17:00:00', (string)$nextNextHour->end); - } - - public function testNextPast() - { - $hours = new Horde_Date_Repeater_Hour(); - $hours->now = $this->now; - - $pastHour = $hours->next('past'); - $this->assertEquals('2006-08-16 13:00:00', (string)$pastHour->begin); - $this->assertEquals('2006-08-16 14:00:00', (string)$pastHour->end); - - $pastPastHour = $hours->next('past'); - $this->assertEquals('2006-08-16 12:00:00', (string)$pastPastHour->begin); - $this->assertEquals('2006-08-16 13:00:00', (string)$pastPastHour->end); - } - - public function testThis() - { - $hours = new Horde_Date_Repeater_Hour(); - $hours->now = new Horde_Date('2006-08-16 14:30:00'); - - $thisHour = $hours->this('future'); - $this->assertEquals('2006-08-16 14:31:00', (string)$thisHour->begin); - $this->assertEquals('2006-08-16 15:00:00', (string)$thisHour->end); - - $thisHour = $hours->this('past'); - $this->assertEquals('2006-08-16 14:00:00', (string)$thisHour->begin); - $this->assertEquals('2006-08-16 14:30:00', (string)$thisHour->end); - } - - public function testOffset() - { - $span = new Horde_Date_Span($this->now, $this->now->add(1)); - $hours = new Horde_Date_Repeater_Hour(); - - $offsetSpan = $hours->offset($span, 3, 'future'); - $this->assertEquals('2006-08-16 17:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-08-16 17:00:01', (string)$offsetSpan->end); - - $offsetSpan = $hours->offset($span, 24, 'past'); - $this->assertEquals('2006-08-15 14:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-08-15 14:00:01', (string)$offsetSpan->end); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/MonthNameTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/MonthNameTest.php deleted file mode 100644 index 2e7d0058c..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/MonthNameTest.php +++ /dev/null @@ -1,67 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testNextFuture() - { - $mays = new Horde_Date_Repeater_MonthName('may'); - $mays->now = $this->now; - - $nextMay = $mays->next('future'); - $this->assertEquals('2007-05-01 00:00:00', (string)$nextMay->begin); - $this->assertEquals('2007-06-01 00:00:00', (string)$nextMay->end); - - $nextNextMay = $mays->next('future'); - $this->assertEquals('2008-05-01 00:00:00', (string)$nextNextMay->begin); - $this->assertEquals('2008-06-01 00:00:00', (string)$nextNextMay->end); - - $decembers = new Horde_Date_Repeater_MonthName('december'); - $decembers->now = $this->now; - - $nextDecember = $decembers->next('future'); - $this->assertEquals('2006-12-01 00:00:00', (string)$nextDecember->begin); - $this->assertEquals('2007-01-01 00:00:00', (string)$nextDecember->end); - } - - public function testNextPast() - { - $mays = new Horde_Date_Repeater_MonthName('may'); - $mays->now = $this->now; - - $this->assertEquals('2006-05-01 00:00:00', (string)$mays->next('past')->begin); - $this->assertEquals('2005-05-01 00:00:00', (string)$mays->next('past')->begin); - } - - public function testThis() - { - $octobers = new Horde_Date_Repeater_MonthName('october'); - $octobers->now = $this->now; - - $thisOctober = $octobers->this('future'); - $this->assertEquals('2006-10-01 00:00:00', (string)$thisOctober->begin); - $this->assertEquals('2006-11-01 00:00:00', (string)$thisOctober->end); - - $aprils = new Horde_Date_Repeater_MonthName('april'); - $aprils->now = $this->now; - - $thisApril = $aprils->this('past'); - $this->assertEquals('2006-04-01 00:00:00', (string)$thisApril->begin); - $this->assertEquals('2006-05-01 00:00:00', (string)$thisApril->end); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/MonthTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/MonthTest.php deleted file mode 100644 index 61395f265..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/MonthTest.php +++ /dev/null @@ -1,40 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testOffsetFuture() - { - $span = new Horde_Date_Span($this->now, $this->now->add(60)); - $repeater = new Horde_Date_Repeater_Month(); - $offsetSpan = $repeater->offset($span, 1, 'future'); - - $this->assertEquals('2006-09-16 14:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-09-16 14:01:00', (string)$offsetSpan->end); - } - - public function testOffsetPast() - { - $span = new Horde_Date_Span($this->now, $this->now->add(60)); - $repeater = new Horde_Date_Repeater_Month(); - $offsetSpan = $repeater->offset($span, 1, 'past'); - - $this->assertEquals('2006-07-16 14:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-07-16 14:01:00', (string)$offsetSpan->end); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/TimeTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/TimeTest.php deleted file mode 100644 index e345455ad..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/TimeTest.php +++ /dev/null @@ -1,81 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testNextFuture() - { - $t = new Horde_Date_Repeater_Time('4:00'); - $t->now = $this->now; - - $this->assertEquals('2006-08-16 16:00:00', (string)$t->next('future')->begin); - $this->assertEquals('2006-08-17 04:00:00', (string)$t->next('future')->begin); - - $t = new Horde_Date_Repeater_Time('13:00'); - $t->now = $this->now; - - $this->assertEquals('2006-08-17 13:00:00', (string)$t->next('future')->begin); - $this->assertEquals('2006-08-18 13:00:00', (string)$t->next('future')->begin); - - $t = new Horde_Date_Repeater_Time('0400'); - $t->now = $this->now; - - $this->assertEquals('2006-08-17 04:00:00', (string)$t->next('future')->begin); - $this->assertEquals('2006-08-18 04:00:00', (string)$t->next('future')->begin); - } - - public function testNextPast() - { - $t = new Horde_Date_Repeater_Time('4:00'); - $t->now = $this->now; - $this->assertEquals('2006-08-16 04:00:00', (string)$t->next('past')->begin); - $this->assertEquals('2006-08-15 16:00:00', (string)$t->next('past')->begin); - - $t = new Horde_Date_Repeater_Time('13:00'); - $t->now = $this->now; - $this->assertEquals('2006-08-16 13:00:00', (string)$t->next('past')->begin); - $this->assertEquals('2006-08-15 13:00:00', (string)$t->next('past')->begin); - } - - public function testType() - { - $t = new Horde_Date_Repeater_Time('4'); - $this->assertEquals(14400, $t->type); - - $t = new Horde_Date_Repeater_Time('14'); - $this->assertEquals(50400, $t->type); - - $t = new Horde_Date_Repeater_Time('4:00'); - $this->assertEquals(14400, $t->type); - - $t = new Horde_Date_Repeater_Time('4:30'); - $this->assertEquals(16200, $t->type); - - $t = new Horde_Date_Repeater_Time('1400'); - $this->assertEquals(50400, $t->type); - - $t = new Horde_Date_Repeater_Time('0400'); - $this->assertEquals(14400, $t->type); - - $t = new Horde_Date_Repeater_Time('04'); - $this->assertEquals(14400, $t->type); - - $t = new Horde_Date_Repeater_Time('400'); - $this->assertEquals(14400, $t->type); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/WeekTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/WeekTest.php deleted file mode 100644 index 8d7865a81..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/WeekTest.php +++ /dev/null @@ -1,78 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testNextFuture() - { - $weeks = new Horde_Date_Repeater_Week(); - $weeks->now = $this->now; - - $nextWeek = $weeks->next('future'); - $this->assertEquals('2006-08-20 00:00:00', (string)$nextWeek->begin); - $this->assertEquals('2006-08-27 00:00:00', (string)$nextWeek->end); - - $nextNextWeek = $weeks->next('future'); - $this->assertEquals('2006-08-27 00:00:00', (string)$nextNextWeek->begin); - $this->assertEquals('2006-09-03 00:00:00', (string)$nextNextWeek->end); - } - - public function testNextPast() - { - $weeks = new Horde_Date_Repeater_Week(); - $weeks->now = $this->now; - - $lastWeek = $weeks->next('past'); - $this->assertEquals('2006-08-06 00:00:00', (string)$lastWeek->begin); - $this->assertEquals('2006-08-13 00:00:00', (string)$lastWeek->end); - - $lastLastWeek = $weeks->next('past'); - $this->assertEquals('2006-07-30 00:00:00', (string)$lastLastWeek->begin); - $this->assertEquals('2006-08-06 00:00:00', (string)$lastLastWeek->end); - } - - public function testThisFuture() - { - $weeks = new Horde_Date_Repeater_Week(); - $weeks->now = $this->now; - - $thisWeek = $weeks->this('future'); - $this->assertEquals('2006-08-16 15:00:00', (string)$thisWeek->begin); - $this->assertEquals('2006-08-20 00:00:00', (string)$thisWeek->end); - } - - public function testThisPast() - { - $weeks = new Horde_Date_Repeater_Week(); - $weeks->now = $this->now; - - $thisWeek = $weeks->this('past'); - $this->assertEquals('2006-08-13 00:00:00', (string)$thisWeek->begin); - $this->assertEquals('2006-08-16 14:00:00', (string)$thisWeek->end); - } - - public function testOffset() - { - $weeks = new Horde_Date_Repeater_Week(); - $span = new Horde_Date_Span($this->now, $this->now->add(1)); - - $offsetSpan = $weeks->offset($span, 3, 'future'); - $this->assertEquals('2006-09-06 14:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-09-06 14:00:01', (string)$offsetSpan->end); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/WeekendTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/WeekendTest.php deleted file mode 100644 index ff053749f..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/WeekendTest.php +++ /dev/null @@ -1,88 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testNextFuture() - { - $weekend = new Horde_Date_Repeater_Weekend(); - $weekend->now = $this->now; - - $nextWeekend = $weekend->next('future'); - $this->assertEquals('2006-08-19 00:00:00', (string)$nextWeekend->begin); - $this->assertEquals('2006-08-21 00:00:00', (string)$nextWeekend->end); - } - - public function testNextPast() - { - $weekend = new Horde_Date_Repeater_Weekend(); - $weekend->now = $this->now; - - $lastWeekend = $weekend->next('past'); - $this->assertEquals('2006-08-12 00:00:00', (string)$lastWeekend->begin); - $this->assertEquals('2006-08-14 00:00:00', (string)$lastWeekend->end); - } - - public function testThisFuture() - { - $weekend = new Horde_Date_Repeater_Weekend(); - $weekend->now = $this->now; - - $thisWeekend = $weekend->this('future'); - $this->assertEquals('2006-08-19 00:00:00', (string)$thisWeekend->begin); - $this->assertEquals('2006-08-21 00:00:00', (string)$thisWeekend->end); - } - - public function testThisPast() - { - $weekend = new Horde_Date_Repeater_Weekend(); - $weekend->now = $this->now; - - $thisWeekend = $weekend->this('past'); - $this->assertEquals('2006-08-12 00:00:00', (string)$thisWeekend->begin); - $this->assertEquals('2006-08-14 00:00:00', (string)$thisWeekend->end); - } - - public function testThisNone() - { - $weekend = new Horde_Date_Repeater_Weekend(); - $weekend->now = $this->now; - - $thisWeekend = $weekend->this('none'); - $this->assertEquals('2006-08-19 00:00:00', (string)$thisWeekend->begin); - $this->assertEquals('2006-08-21 00:00:00', (string)$thisWeekend->end); - } - - public function testOffset() - { - $weekend = new Horde_Date_Repeater_Weekend(); - $span = new Horde_Date_Span($this->now, $this->now->add(1)); - - $offsetSpan = $weekend->offset($span, 3, 'future'); - $this->assertEquals('2006-09-02 00:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-09-02 00:00:01', (string)$offsetSpan->end); - - $offsetSpan = $weekend->offset($span, 1, 'past'); - $this->assertEquals('2006-08-12 00:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-08-12 00:00:01', (string)$offsetSpan->end); - - $offsetSpan = $weekend->offset($span, 0, 'future'); - $this->assertEquals('2006-08-12 00:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2006-08-12 00:00:01', (string)$offsetSpan->end); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/YearTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/YearTest.php deleted file mode 100644 index 0cedf7895..000000000 --- a/framework/Date_Parser/test/Horde/Date/Repeater/YearTest.php +++ /dev/null @@ -1,76 +0,0 @@ -now = new Horde_Date('2006-08-16 14:00:00'); - } - - public function testNextFuture() - { - $years = new Horde_Date_Repeater_Year(); - $years->now = $this->now; - - $nextYear = $years->next('future'); - $this->assertEquals('2007-01-01', $nextYear->begin->format('Y-m-d')); - $this->assertEquals('2008-01-01', $nextYear->end->format('Y-m-d')); - - $nextNextYear = $years->next('future'); - $this->assertEquals('2008-01-01', $nextNextYear->begin->format('Y-m-d')); - $this->assertEquals('2009-01-01', $nextNextYear->end->format('Y-m-d')); - } - - public function testNextPast() - { - $years = new Horde_Date_Repeater_Year(); - $years->now = $this->now; - - $lastYear = $years->next('past'); - $this->assertEquals('2005-01-01', $lastYear->begin->format('Y-m-d')); - $this->assertEquals('2006-01-01', $lastYear->end->format('Y-m-d')); - - $lastLastYear = $years->next('past'); - $this->assertEquals('2004-01-01', $lastLastYear->begin->format('Y-m-d')); - $this->assertEquals('2005-01-01', $lastLastYear->end->format('Y-m-d')); - } - - public function testThis() - { - $years = new Horde_Date_Repeater_Year(); - $years->now = $this->now; - - $thisYear = $years->this('future'); - $this->assertEquals('2006-08-17', $thisYear->begin->format('Y-m-d')); - $this->assertEquals('2007-01-01', $thisYear->end->format('Y-m-d')); - - $thisYear = $years->this('past'); - $this->assertEquals('2006-01-01', $thisYear->begin->format('Y-m-d')); - $this->assertEquals('2006-08-16', $thisYear->end->format('Y-m-d')); - } - - public function testOffset() - { - $span = new Horde_Date_Span($this->now, $this->now->add(1)); - $years = new Horde_Date_Repeater_Year(); - - $offsetSpan = $years->offset($span, 3, 'future'); - $this->assertEquals('2009-08-16 14:00:00', (string)$offsetSpan->begin); - $this->assertEquals('2009-08-16 14:00:01', (string)$offsetSpan->end); - - $offsetSpan = $years->offset($span, 10, 'past'); - $this->assertEquals('1996-08-16 14:00:00', (string)$offsetSpan->begin); - $this->assertEquals('1996-08-16 14:00:01', (string)$offsetSpan->end); - } - -} diff --git a/framework/Date_Parser/test/Horde/Date/SpanTest.php b/framework/Date_Parser/test/Horde/Date/SpanTest.php deleted file mode 100644 index c6424bbe1..000000000 --- a/framework/Date_Parser/test/Horde/Date/SpanTest.php +++ /dev/null @@ -1,38 +0,0 @@ -assertEquals(60 * 60 * 24, $s->width()); - } - - public function testIncludes() - { - $s = new Horde_Date_Span(new Horde_Date('2006-08-16 00:00:00'), new Horde_Date('2006-08-17 00:00:00')); - $this->assertTrue($s->includes(new Horde_Date('2006-08-16 12:00:00'))); - $this->assertFalse($s->includes(new Horde_Date('2006-08-15 00:00:00'))); - $this->assertFalse($s->includes(new Horde_Date('2006-08-18 00:00:00'))); - } - - public function testSpanMath() - { - $s = new Horde_Date_Span(new Horde_Date(1), new Horde_Date(2)); - $this->assertEquals(2, $s->add(1)->begin->timestamp()); - $this->assertEquals(3, $s->add(1)->end->timestamp()); - $this->assertEquals(0, $s->sub(1)->begin->timestamp()); - $this->assertEquals(1, $s->sub(1)->end->timestamp()); - } - -} -- 2.11.0