mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Improve RFC 2822 date parser due to PHP createFromFormat() shortcomings
https://github.com/the-djmaze/snappymail/issues/1694#issuecomment-2270983942
This commit is contained in:
parent
c0ed491f7a
commit
505e6e2a0d
|
@ -42,7 +42,9 @@ abstract class DateTimeHelper
|
|||
}
|
||||
|
||||
$sDateTime = \trim(\preg_replace('/ \([a-zA-Z0-9]+\)$/', '', $sDateTime));
|
||||
$oDateTime = \DateTime::createFromFormat(\DateTime::RFC2822, $sDateTime, static::GetUtcTimeZoneObject());
|
||||
$sDateTime = \preg_replace('/ ([0-9]+:[0-9]+) /', ' $1:00 ', $sDateTime);
|
||||
$oDateTime = \DateTime::createFromFormat(\DateTime::RFC2822, $sDateTime, static::GetUtcTimeZoneObject())
|
||||
?: \DateTime::createFromFormat('d M Y H:i:s O', $sDateTime, static::GetUtcTimeZoneObject());
|
||||
// 398045302 is 1982-08-13 00:08:22 the date RFC 822 was created
|
||||
if (!$oDateTime || 398045302 > $oDateTime->getTimestamp()) {
|
||||
\SnappyMail\Log::notice('', "Failed to parse RFC 2822 date '{$sDateTime}'");
|
||||
|
|
Loading…
Reference in a new issue