@@ 459-478 (lines=20) @@ | ||
456 | $previousOpen = $openingHoursForDay->previousOpen(Time::fromDateTime($dateTime)); |
|
457 | $tries = $this->getDayLimit(); |
|
458 | ||
459 | while ($previousOpen === false || ($previousOpen->hours() === 0 && $previousOpen->minutes() === 0)) { |
|
460 | if (--$tries < 0) { |
|
461 | throw MaximumLimitExceeded::forString( |
|
462 | 'No open date/time found in the previous '.$this->getDayLimit().' days,'. |
|
463 | ' use $openingHours->setDayLimit() to increase the limit.' |
|
464 | ); |
|
465 | } |
|
466 | ||
467 | $midnight = $dateTime->setTime(0, 0, 0); |
|
468 | $dateTime = clone $midnight; |
|
469 | $dateTime = $dateTime->modify('-1 minute'); |
|
470 | ||
471 | $openingHoursForDay = $this->forDate($dateTime); |
|
472 | ||
473 | if ($this->isOpenAt($midnight) && ! $openingHoursForDay->isOpenAt(Time::fromString('23:59'))) { |
|
474 | return $midnight; |
|
475 | } |
|
476 | ||
477 | $previousOpen = $openingHoursForDay->previousOpen(Time::fromDateTime($dateTime)); |
|
478 | } |
|
479 | ||
480 | $nextDateTime = $previousOpen->toDateTime(); |
|
481 | ||
@@ 504-522 (lines=19) @@ | ||
501 | ||
502 | $tries = $this->getDayLimit(); |
|
503 | ||
504 | while ($previousClose === false || ($previousClose->hours() === 0 && $previousClose->minutes() === 0)) { |
|
505 | if (--$tries < 0) { |
|
506 | throw MaximumLimitExceeded::forString( |
|
507 | 'No close date/time found in the previous '.$this->getDayLimit().' days,'. |
|
508 | ' use $openingHours->setDayLimit() to increase the limit.' |
|
509 | ); |
|
510 | } |
|
511 | ||
512 | $midnight = $dateTime->setTime(0, 0, 0); |
|
513 | $dateTime = clone $midnight; |
|
514 | $dateTime = $dateTime->modify('-1 minute'); |
|
515 | $openingHoursForDay = $this->forDate($dateTime); |
|
516 | ||
517 | if ($this->isClosedAt($midnight) && $openingHoursForDay->isOpenAt(Time::fromString('23:59'))) { |
|
518 | return $midnight; |
|
519 | } |
|
520 | ||
521 | $previousClose = $openingHoursForDay->previousClose(Time::fromDateTime($dateTime)); |
|
522 | } |
|
523 | ||
524 | $previousDateTime = $previousClose->toDateTime(); |
|
525 |