Skip to content

Commit

Permalink
Use invariant culture for rendering iso date and time (#16523)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Ros <sebastienros@gmail.com>
  • Loading branch information
github-actions[bot] and sebastienros authored Aug 5, 2024
1 parent fb4e263 commit fe89c06
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using OrchardCore.XmlRpc.Models;
Expand Down Expand Up @@ -27,10 +28,10 @@ public XmlRpcWriter()
{ typeof(bool), p => new XElement("boolean", (bool)p.Value ? "1" : "0") },
{ typeof(string), p => new XElement("string", p.Value) },
{ typeof(double), p => new XElement("double", (double)p.Value) },
{ typeof(DateTime), p => new XElement("dateTime.iso8601", ((DateTime)p.Value).ToString("yyyyMMddTHH:mm:ssZ")) },
{ typeof(DateTime?), p => new XElement("dateTime.iso8601", ((DateTime?)p.Value).Value.ToString("yyyyMMddTHH:mm:ssZ")) },
{ typeof(DateTimeOffset), p => new XElement("dateTime.iso8601", ((DateTimeOffset)p.Value).ToString("yyyyMMddTHH:mm:ssZ")) },
{ typeof(DateTimeOffset?), p => new XElement("dateTime.iso8601", ((DateTimeOffset?)p.Value).Value.ToString("yyyyMMddTHH:mm:ssZ")) },
{ typeof(DateTime), p => new XElement("dateTime.iso8601", ((DateTime)p.Value).ToString("yyyyMMddTHH:mm:ssZ", CultureInfo.InvariantCulture)) },
{ typeof(DateTime?), p => new XElement("dateTime.iso8601", ((DateTime?)p.Value).Value.ToString("yyyyMMddTHH:mm:ssZ", CultureInfo.InvariantCulture)) },
{ typeof(DateTimeOffset), p => new XElement("dateTime.iso8601", ((DateTimeOffset)p.Value).ToString("yyyyMMddTHH:mm:ssZ", CultureInfo.InvariantCulture)) },
{ typeof(DateTimeOffset?), p => new XElement("dateTime.iso8601", ((DateTimeOffset?)p.Value).Value.ToString("yyyyMMddTHH:mm:ssZ", CultureInfo.InvariantCulture)) },
{ typeof(byte[]), p => new XElement("base64", Convert.ToBase64String((byte[])p.Value)) },
{ typeof(XRpcStruct), p => MapStruct((XRpcStruct)p.Value) },
{ typeof(XRpcArray), p => MapArray((XRpcArray)p.Value) },
Expand Down

0 comments on commit fe89c06

Please sign in to comment.