This commit is contained in:
dartcafe 2021-02-20 20:43:53 +01:00
Родитель 5d2ed7b785
Коммит d3281a5b83
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CCE73CEF3035D3C8
2 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -128,10 +128,13 @@ class OptionController extends Controller {
*/ */
public function findCalendarEvents($optionId): DataResponse { public function findCalendarEvents($optionId): DataResponse {
return $this->response(function () use ($optionId) { return $this->response(function () use ($optionId) {
$option = $this->optionService->get($optionId);
$searchFrom = new DateTime(); $searchFrom = new DateTime();
$searchFrom = $searchFrom->setTimestamp($this->optionService->get($optionId)->getTimestamp())->sub(new DateInterval('PT1H')); $searchTo = new DateTime();
$searchTo = clone $searchFrom; // Search calendar entries which end inside one hour before option start time
$searchTo = $searchTo->add(new DateInterval('PT3H')); $searchFrom = $searchFrom->setTimestamp($option->getTimestamp())->sub(new DateInterval('PT1H'));
// Search calendar entries which start inside one hour after option end time
$searchTo = $searchTo->setTimestamp($option->getTimestamp() + $option->getDuration())->add(new DateInterval('PT1H'));
$events = $this->calendarService->getEvents($searchFrom, $searchTo); $events = $this->calendarService->getEvents($searchFrom, $searchTo);
return ['events' => $events]; return ['events' => $events];
}); });

Просмотреть файл

@ -73,7 +73,7 @@ class CalendarService {
// since we get back recurring events of other days, just make sure this event // since we get back recurring events of other days, just make sure this event
// matches the search pattern // matches the search pattern
// TODO: identify possible time zone issues, whan handling all day events // TODO: identify possible time zone issues, when handling all day events
if (($from->getTimestamp() < $calendarEvent->getEnd()) if (($from->getTimestamp() < $calendarEvent->getEnd())
&& ($to->getTimestamp() > $calendarEvent->getStart())) { && ($to->getTimestamp() > $calendarEvent->getStart())) {
array_push($events, $calendarEvent); array_push($events, $calendarEvent);