Skip to content

Commit

Permalink
Updated the IsoDateTimeConverter initialization in the JsonDateTimeFo…
Browse files Browse the repository at this point in the history
…rmatAttribute 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.
  • Loading branch information
miguelcrpinto authored and Zeegaan committed Jun 21, 2023
1 parent 5c5de77 commit 7e573c7
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Buffers;
using System.Globalization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 7e573c7

Please sign in to comment.