From b1a4569ebe1e6b04477b08108d7e3bcad706f232 Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Thu, 3 Feb 2022 09:34:25 +0000 Subject: [PATCH 1/2] fix: add InvariantCulture for DateTimeOffset.Parse --- Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs b/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs index 688b172925f..39254217134 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -30,6 +31,7 @@ public async Task> GetDataAsync() StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri); IRandomAccessStreamWithContentType randomStream = await file.OpenReadAsync(); _items = new ObservableCollection(); + IFormatProvider provider = CultureInfo.InvariantCulture.DateTimeFormat; using (StreamReader sr = new StreamReader(randomStream.AsStreamForRead())) { @@ -48,7 +50,7 @@ public async Task> GetDataAsync() Coordinates = values[4], Prominence = uint.Parse(values[5]), Parent_mountain = values[6], - First_ascent = DateTimeOffset.Parse(values[7]), + First_ascent = DateTimeOffset.Parse(values[7], provider), Ascents = values[8], }); } From acc7f48f1de440019fc0ccafce776af53b4bfe7c Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Fri, 4 Feb 2022 09:20:16 +0000 Subject: [PATCH 2/2] chore: move format provider inline Signed-off-by: HEIGE-PCloud --- Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs b/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs index 39254217134..129ad358be1 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/Data/DataGridDataSource.cs @@ -31,7 +31,6 @@ public async Task> GetDataAsync() StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri); IRandomAccessStreamWithContentType randomStream = await file.OpenReadAsync(); _items = new ObservableCollection(); - IFormatProvider provider = CultureInfo.InvariantCulture.DateTimeFormat; using (StreamReader sr = new StreamReader(randomStream.AsStreamForRead())) { @@ -50,7 +49,7 @@ public async Task> GetDataAsync() Coordinates = values[4], Prominence = uint.Parse(values[5]), Parent_mountain = values[6], - First_ascent = DateTimeOffset.Parse(values[7], provider), + First_ascent = DateTimeOffset.Parse(values[7], CultureInfo.InvariantCulture.DateTimeFormat), Ascents = values[8], }); }