From f4751d3751edd9e3bf7fab13f7c18282a1c4cfae Mon Sep 17 00:00:00 2001 From: Kostub Deshmukh Date: Mon, 22 Feb 2016 17:16:44 -0800 Subject: [PATCH] Use the InvariantCulture to format DateTime. This allows dates in Arabic/Thai locales to be entered correctly in parse. --- ParseCore/Internal/Encoding/ParseEncoder.cs | 2 +- .../Internal/User/Controller/ParseCurrentUserController.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ParseCore/Internal/Encoding/ParseEncoder.cs b/ParseCore/Internal/Encoding/ParseEncoder.cs index 285ead0d..9f7a04e6 100644 --- a/ParseCore/Internal/Encoding/ParseEncoder.cs +++ b/ParseCore/Internal/Encoding/ParseEncoder.cs @@ -40,7 +40,7 @@ public object Encode(object value) { // encoded object. Otherwise, just return the original object. if (value is DateTime) { return new Dictionary { - {"iso", ((DateTime)value).ToString(ParseClient.DateFormatStrings.First())}, + {"iso", ((DateTime)value).ToString(ParseClient.DateFormatStrings.First(), CultureInfo.InvariantCulture)}, {"__type", "Date"} }; } diff --git a/ParseCore/Internal/User/Controller/ParseCurrentUserController.cs b/ParseCore/Internal/User/Controller/ParseCurrentUserController.cs index 54799c9f..45e49802 100644 --- a/ParseCore/Internal/User/Controller/ParseCurrentUserController.cs +++ b/ParseCore/Internal/User/Controller/ParseCurrentUserController.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Globalization; using System.Threading; using System.Threading.Tasks; using Parse.Common.Internal; @@ -46,10 +47,12 @@ public Task SetAsync(ParseUser user, CancellationToken cancellationToken) { var data = user.ServerDataToJSONObjectForSerialization(); data["objectId"] = user.ObjectId; if (user.CreatedAt != null) { - data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatStrings.First()); + data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatStrings.First(), + CultureInfo.InvariantCulture); } if (user.UpdatedAt != null) { - data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatStrings.First()); + data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatStrings.First(), + CultureInfo.InvariantCulture); } saveTask = storageController