Skip to content

Commit f842156

Browse files
authored
Datetime parsing fix, stop converting to local Kind (#2171)
1 parent ce0ce0f commit f842156

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Radzen.Blazor/ExpressionParser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ private Expression ParseStaticInvocation(Type type, string methodName, Parameter
739739
nameof(DateTimeOffset) => typeof(DateTimeOffset),
740740
nameof(Guid) => typeof(Guid),
741741
nameof(CultureInfo) => typeof(CultureInfo),
742+
nameof(DateTimeStyles) => typeof(DateTimeStyles),
742743
nameof(Double) or "double" => typeof(double),
743744
nameof(Single) or "float" => typeof(float),
744745
nameof(Int32) or "int" => typeof(int),

Radzen.Blazor/ExpressionSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private string FormatDateTime(DateTime dateTime)
205205
var finalDate = dateTime.TimeOfDay == TimeSpan.Zero ? dateTime.Date : dateTime;
206206
var dateFormat = dateTime.TimeOfDay == TimeSpan.Zero ? "yyyy-MM-dd" : "yyyy-MM-ddTHH:mm:ss.fffZ";
207207

208-
return $"DateTime.Parse(\"{finalDate.ToString(dateFormat, CultureInfo.InvariantCulture)}\", CultureInfo.InvariantCulture)";
208+
return $"DateTime.Parse(\"{finalDate.ToString(dateFormat, CultureInfo.InvariantCulture)}\", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind)";
209209
}
210210

211211
private string FormatEnumerable(IEnumerable enumerable)

0 commit comments

Comments
 (0)