From 04808eaa66490077b4805501c6d8db6464c5e806 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 25 Sep 2019 09:52:32 +0200 Subject: [PATCH] Include the server timezone in iCal calendar export (closes #379) --- changelog/53_UNRELEASED_2019-xx-xx.md | 1 + controllers/CalendarApiController.php | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/changelog/53_UNRELEASED_2019-xx-xx.md b/changelog/53_UNRELEASED_2019-xx-xx.md index 18f1aca8..c39d246a 100644 --- a/changelog/53_UNRELEASED_2019-xx-xx.md +++ b/changelog/53_UNRELEASED_2019-xx-xx.md @@ -5,6 +5,7 @@ - When adding a product to the shopping list from the new context/more menu from the stock overview page and if the product is already on the shopping list, the amount of that entry will be updated acccordingly instead of adding a new (double) shopping list item - Fixed that the browser barcode scanner button was not clickable on iOS Safari (thanks @DeeeeLAN) - Fixed a problem regarding quantity unit conversion handling for recipe ingredients of products with no unit relations, but only a different purchase/stock quantity unit +- Improved that dates in the iCal calendar export now includes the server timezone - The API Endpoint `GET /files/{group}/{fileName}` now also returns a `Cache-Control` header (defaults fixed to 30 days) to further increase page load times - Fixed that the API endpoint `/stock/shoppinglist/add-product` failed when a product should be added which was not already on the shopping list (thanks @Forceu) - Some style/CSS detail-refinements diff --git a/controllers/CalendarApiController.php b/controllers/CalendarApiController.php index e579e532..a641a553 100644 --- a/controllers/CalendarApiController.php +++ b/controllers/CalendarApiController.php @@ -26,12 +26,20 @@ class CalendarApiController extends BaseApiController $events = $this->CalendarService->GetEvents(); foreach($events as $event) { + $date = new \DateTime($event['start']); + $date->setTimezone(date_default_timezone_get()); + + if ($event['date_format'] === 'date') + { + $date->setTime(23, 59, 59); + } + $vEvent = new \Eluceo\iCal\Component\Event(); - $vEvent->setDtStart(new \DateTime($event['start'])) - ->setDtEnd(new \DateTime($event['start'])) + $vEvent->setDtStart($date) + ->setDtEnd($date) ->setSummary($event['title']) ->setNoTime($event['date_format'] === 'date') - ->setUseUtc(false); + ->setUseTimezone(true); $vCalendar->addComponent($vEvent); }