diff --git a/source/connector-mobilizon.php b/source/connector-mobilizon.php
index 7c853e1..2a62b8e 100644
--- a/source/connector-mobilizon.php
+++ b/source/connector-mobilizon.php
@@ -17,8 +17,7 @@ require_once __DIR__ . '/includes/Api.php';
require_once __DIR__ . '/includes/EventsCache.php';
require_once __DIR__ . '/includes/Settings.php';
require_once __DIR__ . '/includes/SiteSettings.php';
-require_once __DIR__ . '/includes/LocalDateTime.php';
-require_once __DIR__ . '/includes/LocalDateTimeFormatter.php';
+require_once __DIR__ . '/includes/DateTimeFormatter.php';
require_once __DIR__ . '/includes/LineFormatter.php';
require_once __DIR__ . '/includes/GraphQlClient.php';
require_once __DIR__ . '/includes/EventsListBlock.php';
diff --git a/source/includes/DateTimeFormatter.php b/source/includes/DateTimeFormatter.php
new file mode 100644
index 0000000..88a55de
--- /dev/null
+++ b/source/includes/DateTimeFormatter.php
@@ -0,0 +1,10 @@
+getTimestamp();
+ return date_i18n($format, $timestamp);
+ }
+}
diff --git a/source/includes/EventsListBlock.php b/source/includes/EventsListBlock.php
index f91084c..c0fa566 100644
--- a/source/includes/EventsListBlock.php
+++ b/source/includes/EventsListBlock.php
@@ -53,7 +53,6 @@ class EventsListBlock {
$dateFormat = SiteSettings::getDateFormat();
$timeFormat = SiteSettings::getTimeFormat();
- $timeZone = SiteSettings::getTimeZone();
require dirname(__DIR__) . '/view/events-list.php';
} catch (GeneralException $e) {
diff --git a/source/includes/EventsListShortcut.php b/source/includes/EventsListShortcut.php
index 9a26a77..082b164 100644
--- a/source/includes/EventsListShortcut.php
+++ b/source/includes/EventsListShortcut.php
@@ -36,7 +36,6 @@ class EventsListShortcut {
$dateFormat = SiteSettings::getDateFormat();
$timeFormat = SiteSettings::getTimeFormat();
- $timeZone = SiteSettings::getTimeZone();
require dirname(__DIR__) . '/view/events-list.php';
} catch (GeneralException $e) {
diff --git a/source/includes/EventsListWidget.php b/source/includes/EventsListWidget.php
index e4fbd88..f038702 100644
--- a/source/includes/EventsListWidget.php
+++ b/source/includes/EventsListWidget.php
@@ -36,7 +36,6 @@ class EventsListWidget extends \WP_Widget {
$dateFormat = SiteSettings::getDateFormat();
$timeFormat = SiteSettings::getTimeFormat();
- $timeZone = SiteSettings::getTimeZone();
require dirname(__DIR__) . '/view/events-list.php';
} catch (GeneralException $e) {
diff --git a/source/includes/LineFormatter.php b/source/includes/LineFormatter.php
index 897ad25..42a6c7b 100644
--- a/source/includes/LineFormatter.php
+++ b/source/includes/LineFormatter.php
@@ -3,16 +3,16 @@ namespace MobilizonConnector;
final class LineFormatter
{
- public static function format_date_time(\DateTimeZone $timeZone, string $dateFormat, string $timeFormat, string $start, ?string $end): string {
- $startDateTime = new LocalDateTime($start, $timeZone);
- $startDate = LocalDateTimeFormatter::format($startDateTime, $dateFormat);
- $startTime = LocalDateTimeFormatter::format($startDateTime, $timeFormat);
+ public static function format_date_time(string $dateFormat, string $timeFormat, string $start, ?string $end): string {
+ $startDateTime = new \DateTimeImmutable($start);
+ $startDate = DateTimeFormatter::format($startDateTime, $dateFormat);
+ $startTime = DateTimeFormatter::format($startDateTime, $timeFormat);
$dateText = $startDate . ' ' . $startTime;
if ($end) {
- $endDateTime = new LocalDateTime($end, $timeZone);
- $endDate = LocalDateTimeFormatter::format($endDateTime, $dateFormat);
- $endTime = LocalDateTimeFormatter::format($endDateTime, $timeFormat);
+ $endDateTime = new \DateTimeImmutable($end);
+ $endDate = DateTimeFormatter::format($endDateTime, $dateFormat);
+ $endTime = DateTimeFormatter::format($endDateTime, $timeFormat);
if ($startDate != $endDate) {
$dateText .= ' - ';
diff --git a/source/includes/LocalDateTime.php b/source/includes/LocalDateTime.php
deleted file mode 100644
index b8c3264..0000000
--- a/source/includes/LocalDateTime.php
+++ /dev/null
@@ -1,15 +0,0 @@
-dateTime = $date->setTimezone($timeZone);
- }
-
- public function getValue() {
- return $this->dateTime;
- }
-}
diff --git a/source/includes/LocalDateTimeFormatter.php b/source/includes/LocalDateTimeFormatter.php
deleted file mode 100644
index 78e8ae1..0000000
--- a/source/includes/LocalDateTimeFormatter.php
+++ /dev/null
@@ -1,10 +0,0 @@
-getValue()->getTimestamp();
- return date_i18n($format, $timestamp);
- }
-}
diff --git a/source/includes/SiteSettings.php b/source/includes/SiteSettings.php
index 1b91059..8b779f2 100644
--- a/source/includes/SiteSettings.php
+++ b/source/includes/SiteSettings.php
@@ -14,8 +14,4 @@ class SiteSettings {
return get_option(self::$OPTION_NAME_TIME_FORMAT);
}
- public static function getTimeZone() {
- return wp_timezone();
- }
-
}
diff --git a/source/view/events-list.php b/source/view/events-list.php
index 8bd3bc6..7cf046c 100644
--- a/source/view/events-list.php
+++ b/source/view/events-list.php
@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
-
+
diff --git a/tests/LineFormatterTest.php b/tests/LineFormatterTest.php
index 4294b66..fd58bf3 100644
--- a/tests/LineFormatterTest.php
+++ b/tests/LineFormatterTest.php
@@ -25,15 +25,15 @@ function date_i18n(string $format, int $timestamp) {
final class LineFormatterTest extends TestCase
{
public function testCanDateFormatOneDate(): void {
- $this->assertSame('15/04/2021 10:30 - 15:30', LineFormatter::format_date_time(new \DateTimeZone('UTC'), 'd/m/Y', 'H:i', '2021-04-15T10:30:00Z', '2021-04-15T15:30:00Z'));
+ $this->assertSame('15/04/2021 10:30 - 15:30', LineFormatter::format_date_time('d/m/Y', 'H:i', '2021-04-15T10:30:00Z', '2021-04-15T15:30:00Z'));
}
public function testCanDateFormatTwoDates(): void {
- $this->assertSame('15/04/2021 10:30 - 16/04/2021 15:30', LineFormatter::format_date_time(new \DateTimeZone('UTC'), 'd/m/Y', 'H:i', '2021-04-15T10:30:00Z', '2021-04-16T15:30:00Z'));
+ $this->assertSame('15/04/2021 10:30 - 16/04/2021 15:30', LineFormatter::format_date_time('d/m/Y', 'H:i', '2021-04-15T10:30:00Z', '2021-04-16T15:30:00Z'));
}
public function testCanDateFormatWhenSecondDateIsNull(): void {
- $this->assertSame('15/04/2021 10:30', LineFormatter::format_date_time(new \DateTimeZone('UTC'), 'd/m/Y', 'H:i', '2021-04-15T10:30:00Z', null));
+ $this->assertSame('15/04/2021 10:30', LineFormatter::format_date_time('d/m/Y', 'H:i', '2021-04-15T10:30:00Z', null));
}
public function testCanLocationFormatBothParameters(): void {
diff --git a/tests/LocalDateTimeTest.php b/tests/LocalDateTimeTest.php
deleted file mode 100644
index 19e15aa..0000000
--- a/tests/LocalDateTimeTest.php
+++ /dev/null
@@ -1,12 +0,0 @@
-assertEquals(new DateTimeImmutable('2020-12-24T16:45:00Z'), $d->getValue());
- }
-}