From 61c650db0bd1652070ac198aeb4510882e6a33c7 Mon Sep 17 00:00:00 2001 From: Taras Shevchuk Date: Tue, 14 Nov 2023 17:40:45 +0200 Subject: [PATCH 1/2] Fixed DateTimeOffset.Now calls on Android with specific conditions Fixed issue when DateTimeOffset.Now throws exception on Android with Arabic language & western hemisphere timezone --- .../src/System/DateTimeOffset.Android.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs b/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs index c40e4708e47aab..fa689e4b0689f3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Threading; +using System.Globalization; namespace System { @@ -60,7 +61,7 @@ public static DateTimeOffset Now } // Fast path obtained offset incorporated into ToLocalTime(DateTime.UtcNow, true) logic - int localDateTimeOffsetSeconds = Convert.ToInt32(localDateTimeOffset); + int localDateTimeOffsetSeconds = Convert.ToInt32(localDateTimeOffset, CultureInfo.InvariantCulture); TimeSpan offset = TimeSpan.FromSeconds(localDateTimeOffsetSeconds); long localTicks = utcDateTime.Ticks + offset.Ticks; if (localTicks < DateTime.MinTicks || localTicks > DateTime.MaxTicks) From 16e1754c9b29dd6616901c4c9627d038dca29c4f Mon Sep 17 00:00:00 2001 From: Taras Shevchuk Date: Tue, 14 Nov 2023 18:06:50 +0200 Subject: [PATCH 2/2] Fixed usings order --- .../System.Private.CoreLib/src/System/DateTimeOffset.Android.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs b/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs index fa689e4b0689f3..e9ca7bb3eeb877 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Threading; using System.Globalization; +using System.Threading; namespace System {