Skip to content

Commit

Permalink
Improve comment remove process
Browse files Browse the repository at this point in the history
  • Loading branch information
pupaxxo committed Dec 18, 2019
1 parent 976c7a2 commit 5c41139
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/Message/AbstractMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,13 @@ final public function getDate(): ?\DateTimeImmutable
$alteredValue = $dateHeader;
$alteredValue = \str_replace(',', '', $alteredValue);
$alteredValue = (string) \preg_replace('/^[a-zA-Z]+ ?/', '', $alteredValue);
$alteredValue = (string) \preg_replace('/ +\(.*\)/', '', $alteredValue);
$alteredValue = (string) \preg_replace('/\(.*\)/', '', $alteredValue);
$alteredValue = (string) \preg_replace('/\bUT\b/', 'UTC', $alteredValue);
if (0 === \preg_match('/\d\d:\d\d:\d\d.* [\+\-]\d\d:?\d\d/', $alteredValue)) {
$alteredValue .= ' +0000';
}
// Handle numeric months
$alteredValue = (string) \preg_replace('/^(\d\d) (\d\d) (\d\d(?:\d\d)?) /', '$3-$2-$1 ', $alteredValue);
// Handle comments as specified in RFC2822
$alteredValue = (string) \preg_replace('/^\s*\(.*?\)\s*/', '', $alteredValue);
$alteredValue = (string) \preg_replace('/\s*\(.*?\)\s*$/', '', $alteredValue);

try {
$date = new \DateTimeImmutable($alteredValue);
Expand Down

0 comments on commit 5c41139

Please sign in to comment.