Skip to content
This repository has been archived by the owner on Jun 21, 2018. It is now read-only.

Commit

Permalink
opravy na základě aktualizovaných testů
Browse files Browse the repository at this point in the history
  • Loading branch information
stekycz committed Oct 25, 2012
1 parent 3b5c337 commit e61e895
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions DatePaginator/DatePaginator.php
Expand Up @@ -110,6 +110,9 @@ public function getPreviousDate() {
$previous_date = clone $this->date;
$previous_date = $previous_date->modify('- ' . $this->period->getPeriod());
$closest_previous = $this->period->normalizeDate($this->model->getClosestPrevious($this->date));
if ($closest_previous < $this->model->getOldestDate()) {
$closest_previous = $this->model->getOldestDate();
}
if ($closest_previous < $previous_date) {
$previous_date = clone $closest_previous;
}
Expand All @@ -129,6 +132,9 @@ public function getNextDate() {
$next_date = clone $this->date;
$next_date = $next_date->modify('+ ' . $this->period->getPeriod());
$closest_next = $this->period->normalizeDate($this->model->getClosestNext($this->date));
if ($closest_next > $this->model->getNewestDate()) {
$closest_next = $this->model->getNewestDate();
}
if ($closest_next > $next_date) {
$next_date = clone $closest_next;
}
Expand All @@ -139,11 +145,11 @@ public function getNextDate() {
* Vrací počet dní mezi nejstarším a nejnovějším datem.
*
* @return int
* @throws InvalidStateException Pokud zjistíme, že neest date je starší než oldest
* @throws \steky\nette\DatePaginator\InvalidStateException Pokud zjistíme, že neest date je starší než oldest
*/
public function getDays() {
if ($this->getNewestDate() < $this->getOldestDate()) {
throw new InvalidStateException('Newest date is older than Oldest date.');
throw new InvalidStateException('Newest date cannot be older than Oldest date.');
}
$difference = $this->getNewestDate()->diff($this->getOldestDate());
return (int) $difference->days;
Expand Down

0 comments on commit e61e895

Please sign in to comment.