Skip to content

Commit d111647

Browse files
tagcodeToni Kalajainen
andauthored
Sitemap.xml "lastmod" had erroneous datetimes in some locales. (#8105)
Sitemap.xml "lastmode" had erroneous datetimes in some locales. In 'fi' CultureInfo DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssK") returns "2022-07-25T10.21.47+03:00". Colons were converted into dots '.'. Google did not index the site due to datetime errors. Co-authored-by: Toni Kalajainen <toni.kalajainen@iki.fi>
1 parent 662aa7d commit d111647

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Microsoft.DocAsCode.Build.Engine/PostProcessors/SitemapGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Microsoft.DocAsCode.Build.Engine
77
using System.Collections.Generic;
88
using System.Collections.Immutable;
99
using System.Composition;
10+
using System.Globalization;
1011
using System.IO;
1112
using System.Linq;
1213
using System.Xml.Linq;
@@ -115,7 +116,7 @@ private XElement GetElement(string relativePath, Uri baseUri, SitemapElementOpti
115116
return new XElement
116117
(Namespace + "url",
117118
new XElement(Namespace + "loc", uri.AbsoluteUri),
118-
new XElement(Namespace + "lastmod", (options.LastModified ?? DateTime.Now).ToString("yyyy-MM-ddThh:mm:ssK")),
119+
new XElement(Namespace + "lastmod", (options.LastModified ?? DateTime.Now).ToString("yyyy-MM-ddThh:mm:ssK", CultureInfo.InvariantCulture)),
119120
new XElement(Namespace + "changefreq", (options.ChangeFrequency ?? PageChangeFrequency.Daily).ToString().ToLowerInvariant()),
120121
new XElement(Namespace + "priority", options.Priority ?? 0.5)
121122
);

0 commit comments

Comments
 (0)