From a6e720679c5ff354513156de7a94d94a2603ab8b Mon Sep 17 00:00:00 2001 From: Daniel Waxweiler Date: Mon, 26 May 2025 16:21:02 +0200 Subject: [PATCH] fix offset --- source/includes/LocalDateTime.php | 4 ++-- source/includes/LocalDateTimeFormatter.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/includes/LocalDateTime.php b/source/includes/LocalDateTime.php index b8c3264..68cc1d6 100644 --- a/source/includes/LocalDateTime.php +++ b/source/includes/LocalDateTime.php @@ -4,8 +4,8 @@ namespace MobilizonConnector; final class LocalDateTime { private $dateTime; - public function __construct(string $text, \DateTimeZone $timeZone) { - $date = new \DateTimeImmutable($text); + public function __construct(string $dateTimeString, \DateTimeZone $timeZone) { + $date = new \DateTimeImmutable($dateTimeString); $this->dateTime = $date->setTimezone($timeZone); } diff --git a/source/includes/LocalDateTimeFormatter.php b/source/includes/LocalDateTimeFormatter.php index 78e8ae1..9141e34 100644 --- a/source/includes/LocalDateTimeFormatter.php +++ b/source/includes/LocalDateTimeFormatter.php @@ -5,6 +5,8 @@ final class LocalDateTimeFormatter { public static function format(LocalDateTime $dateTime, string $format) { $timestamp = $dateTime->getValue()->getTimestamp(); - return date_i18n($format, $timestamp); + $offset = $dateTime->getValue()->getOffset(); + $timestampWithOffset = $timestamp + $offset; + return date_i18n($format, $timestampWithOffset); } }