Skip to content

Commit 4bbcb4b

Browse files
committed
Additional timestamp format added Webklex#392
1 parent 8ff2782 commit 4bbcb4b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
1414
- Catching and handling iconv decoding exception #397
1515

1616
### Added
17-
- NaN
17+
- Additional timestamp format added #392 (thanks @esk-ap)
1818

1919
### Breaking changes
2020
- NaN

src/Header.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,11 @@ private function parseDate(object $header): void {
716716
array_splice($parts, -2);
717717
$date = implode(' ', $parts);
718718
break;
719+
case preg_match('/([A-Z]{2,4}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4})+$/i', $date) > 0:
720+
$array = explode(',', $date);
721+
array_shift($array);
722+
$date = Carbon::createFromFormat("d M Y H:i:s O", trim(implode(',', $array)));
723+
break;
719724
case preg_match('/([0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ UT)+$/i', $date) > 0:
720725
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ UT)+$/i', $date) > 0:
721726
$date .= 'C';

tests/fixtures/DateTemplateTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class DateTemplateTest extends FixtureTestCase {
4848
"14 Sep 2019 00:10:08 UT +0200" => "2019-09-14 00:10:08",
4949
"Tue, 08 Nov 2022 18:47:20 +0000 14:03:33 +0000" => "2022-11-08 18:47:20",
5050
"Sat, 10, Dec 2022 09:35:19 +0100" => "2022-12-10 08:35:19",
51+
"Thur, 16 Mar 2023 15:33:07 +0400" => "2023-03-16 11:33:07",
5152
];
5253

5354
/**

0 commit comments

Comments
 (0)