Skip to content

Commit

Permalink
use end date on single day events (closes #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Feb 12, 2020
1 parent 868549b commit cc186e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Events/Types/SingleDayEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public function upcomingDate($after = null): ?Schedule
return null;
}

return Schedule::fromCarbon($this->start());
return new Schedule([
'date' => $this->start_date,
'start_time' => $this->startTime(),
'end_time' => $this->endTime(),
]);
}

public function upcomingDates($limit = 2, $offset = 0): Collection
Expand Down
4 changes: 4 additions & 0 deletions Events/tests/SingleDayEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public function test_can_generate_next_datetime_if_before()
carbon('2019-11-27')->setTimeFromTimeString('11:00:00'),
$this->nonAllDayEvent->upcomingDate(carbon('2019-11-22'))->start()
);
$this->assertEquals(
carbon('2019-11-27')->setTimeFromTimeString('12:00:00'),
$this->nonAllDayEvent->upcomingDate(carbon('2019-11-22'))->end()
);
}

public function test_returns_start_if_during()
Expand Down

0 comments on commit cc186e6

Please sign in to comment.