Skip to content

Commit 467099f

Browse files
[release/8.0-staging] [main] Fixed DateTimeOffset.Now calls on Android with specific conditions (#94718)
Fixed issue when DateTimeOffset.Now throws exception on Android with Arabic language & western hemisphere timezone Backport of #94710 Co-authored-by: Taras Shevchuk <[email protected]>
1 parent 5acd05e commit 467099f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.Android.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Globalization;
45
using System.Threading;
56

67
namespace System
@@ -60,7 +61,7 @@ public static DateTimeOffset Now
6061
}
6162

6263
// Fast path obtained offset incorporated into ToLocalTime(DateTime.UtcNow, true) logic
63-
int localDateTimeOffsetSeconds = Convert.ToInt32(localDateTimeOffset);
64+
int localDateTimeOffsetSeconds = Convert.ToInt32(localDateTimeOffset, CultureInfo.InvariantCulture);
6465
TimeSpan offset = TimeSpan.FromSeconds(localDateTimeOffsetSeconds);
6566
long localTicks = utcDateTime.Ticks + offset.Ticks;
6667
if (localTicks < DateTime.MinTicks || localTicks > DateTime.MaxTicks)

0 commit comments

Comments
 (0)