Skip to content

Commit

Permalink
fix: appointment slots start and end time
Browse files Browse the repository at this point in the history
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
  • Loading branch information
SebastianKrupinski committed Nov 16, 2024
1 parent 9eb17f3 commit a06a01c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
12 changes: 4 additions & 8 deletions lib/Controller/BookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,11 @@ public function getBookableSlots(int $appointmentConfigId,
$this->logger->error('Timezone invalid', ['exception' => $e]);
return JsonResponse::fail('Invalid time zone', Http::STATUS_UNPROCESSABLE_ENTITY);
}
$startTimeInTz = (new DateTimeImmutable())
->setTimestamp($startTime)
->setTimezone($tz)
->setTime(0, 0)

$startTimeInTz = (new DateTimeImmutable("@$startTime", $tz))
->getTimestamp();
$endTimeInTz = (new DateTimeImmutable())
->setTimestamp($startTime)
->setTimezone($tz)
->setTime(23, 59, 59)
$endTimeInTz = (new DateTimeImmutable("@$startTime", $tz))
->modify('+1 day')
->getTimestamp();

if ($startTimeInTz > $endTimeInTz) {
Expand Down
11 changes: 3 additions & 8 deletions tests/php/unit/Controller/BookingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,10 @@ protected function setUp():void {
public function testGetBookableSlots(): void {
$start = time();
$tz = new DateTimeZone('Europe/Berlin');
$sDT = (new DateTimeImmutable())
->setTimestamp($start)
->setTimezone($tz)
->setTime(0, 0)
$sDT = (new DateTimeImmutable("@$start", $tz))
->getTimestamp();
$eDT = (new DateTimeImmutable())
->setTimestamp($start)
->setTimezone($tz)
->setTime(23, 59, 59)
$eDT = (new DateTimeImmutable("@$start", $tz))
->modify('+1 day')
->getTimestamp();

$apptConfg = new AppointmentConfig();
Expand Down

0 comments on commit a06a01c

Please sign in to comment.