From b6f3f298fed9cee0eac2839870664683fdae9654 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 30 Dec 2022 21:40:37 -0500 Subject: [PATCH] Add new case to DateTimeFormat::fix - Address https://github.com/friendica/friendica/issues/12488#issuecomment-1368011436 --- src/Util/DateTimeFormat.php | 4 ++-- tests/src/Util/DateTimeFormatTest.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index 8233a4f5b6..6b11a54580 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -182,8 +182,8 @@ class DateTimeFormat */ public static function fix(string $dateString): string { - $search = ['Mär', 'März', 'Mai', 'Juni', 'Juli', 'Okt', 'Dez', 'ET' , 'ZZ', ' - ', '+']; - $replace = ['Mar', 'Mar' , 'May', 'Jun' , 'Jul' , 'Oct', 'Dec', 'EST', 'Z' , ', ' , '+' ]; + $search = ['Mär', 'März', 'Mai', 'Juni', 'Juli', 'Okt', 'Dez', 'ET' , 'ZZ', ' - ', '+', ' (Coordinated Universal Time)']; + $replace = ['Mar', 'Mar' , 'May', 'Jun' , 'Jul' , 'Oct', 'Dec', 'EST', 'Z' , ', ' , '+' , '']; $dateString = str_replace($search, $replace, $dateString); diff --git a/tests/src/Util/DateTimeFormatTest.php b/tests/src/Util/DateTimeFormatTest.php index 994ca3a113..41f646bada 100644 --- a/tests/src/Util/DateTimeFormatTest.php +++ b/tests/src/Util/DateTimeFormatTest.php @@ -126,6 +126,10 @@ class DateTimeFormatTest extends MockedTest 'German date time string' => [ 'expectedDate' => '2022-10-05T16:34:00+02:00', 'dateString' => '05 Okt 2022 16:34:00 +0200', + ], + '(Coordinated Universal Time)' => [ + 'expectedDate' => '2022-12-30T14:29:10+00:00', + 'dateString' => 'Fri Dec 30 2022 14:29:10 GMT+0000 (Coordinated Universal Time)', ] ]; }