@@ 438-457 (lines=20) @@ | ||
435 | $previousOpen = $openingHoursForDay->previousOpen(Time::fromDateTime($dateTime)); |
|
436 | $tries = $this->getDayLimit(); |
|
437 | ||
438 | while ($previousOpen === false || ($previousOpen->hours() === 0 && $previousOpen->minutes() === 0)) { |
|
439 | if (--$tries < 0) { |
|
440 | throw MaximumLimitExceeded::forString( |
|
441 | 'No open date/time found in the previous '.$this->getDayLimit().' days,'. |
|
442 | ' use $openingHours->setDayLimit() to increase the limit.' |
|
443 | ); |
|
444 | } |
|
445 | ||
446 | $midnight = $dateTime->setTime(0, 0, 0); |
|
447 | $dateTime = clone $midnight; |
|
448 | $dateTime = $dateTime->modify('-1 minute'); |
|
449 | ||
450 | $openingHoursForDay = $this->forDate($dateTime); |
|
451 | ||
452 | if ($this->isOpenAt($midnight) && ! $openingHoursForDay->isOpenAt(Time::fromString('23:59'))) { |
|
453 | return $midnight; |
|
454 | } |
|
455 | ||
456 | $previousOpen = $openingHoursForDay->previousOpen(Time::fromDateTime($dateTime)); |
|
457 | } |
|
458 | ||
459 | $nextDateTime = $previousOpen->toDateTime(); |
|
460 | ||
@@ 483-501 (lines=19) @@ | ||
480 | ||
481 | $tries = $this->getDayLimit(); |
|
482 | ||
483 | while ($previousClose === false || ($previousClose->hours() === 0 && $previousClose->minutes() === 0)) { |
|
484 | if (--$tries < 0) { |
|
485 | throw MaximumLimitExceeded::forString( |
|
486 | 'No close date/time found in the previous '.$this->getDayLimit().' days,'. |
|
487 | ' use $openingHours->setDayLimit() to increase the limit.' |
|
488 | ); |
|
489 | } |
|
490 | ||
491 | $midnight = $dateTime->setTime(0, 0, 0); |
|
492 | $dateTime = clone $midnight; |
|
493 | $dateTime = $dateTime->modify('-1 minute'); |
|
494 | $openingHoursForDay = $this->forDate($dateTime); |
|
495 | ||
496 | if ($this->isClosedAt($midnight) && $openingHoursForDay->isOpenAt(Time::fromString('23:59'))) { |
|
497 | return $midnight; |
|
498 | } |
|
499 | ||
500 | $previousClose = $openingHoursForDay->previousClose(Time::fromDateTime($dateTime)); |
|
501 | } |
|
502 | ||
503 | $previousDateTime = $previousClose->toDateTime(); |
|
504 |