missing changes
This commit is contained in:
Родитель
5d2ed7b785
Коммит
d3281a5b83
|
@ -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);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче