Skip to content

Commit 6b775f4

Browse files
authored
Merge branch 'develop' into feature/sec-2025-11-21
2 parents 72c3e43 + cc55346 commit 6b775f4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
66

77
- [#330](https://github.com/os2display/display-api-service/pull/330)
88
- Composer update.
9+
- [#333](https://github.com/os2display/display-api-service/pull/333)
10+
- Fix date parsing issue in BRND booking feed type
911
- [#313](https://github.com/os2display/display-api-service/pull/313)
1012
- Add BRND booking feed type
1113

src/Feed/BrndFeedType.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class BrndFeedType implements FeedTypeInterface
2424

2525
final public const string SUPPORTED_FEED_TYPE = FeedOutputModels::BRND_BOOKING_OUTPUT;
2626

27+
/**
28+
* BRND api datetime values are always given as 'Europe/Copenhagen'.
29+
*/
30+
private const string BRND_API_TIMEZONE = 'Europe/Copenhagen';
31+
2732
public function __construct(
2833
private readonly FeedService $feedService,
2934
private readonly ApiClient $apiClient,
@@ -94,6 +99,7 @@ public function getData(Feed $feed): array
9499

95100
private function parseBrndBooking(array $booking): array
96101
{
102+
$tz = new \DateTimeZone(self::BRND_API_TIMEZONE);
97103
// Parse start time
98104
$startDateTime = null;
99105
if (!empty($booking['dato']) && isset($booking['starttid']) && is_string($booking['starttid'])) {
@@ -102,7 +108,7 @@ private function parseBrndBooking(array $booking): array
102108
$startTimeString = preg_replace('/\.(\d{6})\d+$/', '.$1', $booking['starttid']);
103109
$dateOnly = substr((string) $booking['dato'], 0, 10);
104110
$dateTimeString = $dateOnly.' '.$startTimeString;
105-
$startDateTime = \DateTimeImmutable::createFromFormat('m/d/Y H:i:s.u', $dateTimeString);
111+
$startDateTime = \DateTimeImmutable::createFromFormat('m/d/Y H:i:s.u', $dateTimeString, $tz);
106112
if (false === $startDateTime) {
107113
$startDateTime = null;
108114
}
@@ -118,7 +124,7 @@ private function parseBrndBooking(array $booking): array
118124
$endTimeString = preg_replace('/\.(\d{6})\d+$/', '.$1', $booking['sluttid']);
119125
$dateOnly = substr((string) $booking['dato'], 0, 10);
120126
$dateTimeString = $dateOnly.' '.$endTimeString;
121-
$endDateTime = \DateTimeImmutable::createFromFormat('m/d/Y H:i:s.u', $dateTimeString);
127+
$endDateTime = \DateTimeImmutable::createFromFormat('m/d/Y H:i:s.u', $dateTimeString, $tz);
122128
if (false === $endDateTime) {
123129
$endDateTime = null;
124130
}

0 commit comments

Comments
 (0)