From 7e573c70a3aa0aeb7992de1bab9823d26b458c3e Mon Sep 17 00:00:00 2001 From: miguelcrpinto Date: Sat, 17 Jun 2023 10:28:53 +0200 Subject: [PATCH] Updated the IsoDateTimeConverter initialization in the JsonDateTimeFormatAttribute to set the Culture to InvariantCulture so that the custom DateTime format symbols ( date and time separators) are respected independent of the CurrentCulture being used. --- src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs b/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs index 247a2a09ba7a..0e0cf5587dbf 100644 --- a/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs +++ b/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs @@ -1,4 +1,5 @@ using System.Buffers; +using System.Globalization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Options; @@ -42,7 +43,7 @@ public void OnResultExecuting(ResultExecutingContext context) { var serializerSettings = new JsonSerializerSettings(); serializerSettings.Converters.Add( - new IsoDateTimeConverter { DateTimeFormat = _format }); + new IsoDateTimeConverter { DateTimeFormat = _format, Culture = CultureInfo.InvariantCulture }); objectResult.Formatters.Clear(); objectResult.Formatters.Add( new AngularJsonMediaTypeFormatter(serializerSettings, _arrayPool, _options));