Skip to content

Commit

Permalink
Merge pull request #248 from eliashaeussler/fix/lastmod-no-time
Browse files Browse the repository at this point in the history
[BUGFIX] Support <lastmod> without time
  • Loading branch information
eliashaeussler authored Mar 30, 2023
2 parents 1653609 + ced6cd0 commit 9c8709f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Xml/XmlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ static function (Throwable $exception) {
throw $exception;
},
)
->supportDateFormats(DateTimeInterface::W3C)
->supportDateFormats(
DateTimeInterface::W3C,
'!Y-m-d',
)
->mapper()
;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Fixtures/valid_sitemap_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<url>
<loc>https://www.example.org/</loc>
<priority>0.8</priority>
<lastmod>2022-05-02T12:14:44+02:00</lastmod>
<lastmod>2022-05-02</lastmod>
<changefreq>yearly</changefreq>
</url>
<url>
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Mapper/Source/XmlSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function fromXmlConvertsXmlToArray(): void
[
'loc' => 'https://www.example.org/',
'priority' => '0.8',
'lastmod' => '2022-05-02T12:14:44+02:00',
'lastmod' => '2022-05-02',
'changefreq' => 'yearly',
],
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Xml/XmlParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function parseParsesSitemapUrlSet(): void
new Sitemap\Url(
uri: 'https://www.example.org/',
priority: 0.8,
lastModificationDate: new DateTimeImmutable('2022-05-02T12:14:44+02:00'),
lastModificationDate: new DateTimeImmutable('2022-05-02T00:00:00+00:00'),
changeFrequency: Sitemap\ChangeFrequency::Yearly,
),
new Sitemap\Url(
Expand Down

0 comments on commit 9c8709f

Please sign in to comment.