From 7a94213803351f70b9338ca17954191831d5363f Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Mon, 7 Aug 2023 06:07:22 +0800 Subject: [PATCH] TimeProvider GetLocalNow enhancement (#90066) Co-authored-by: Tarek Mahmoud Sayed --- src/libraries/Common/src/System/TimeProvider.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libraries/Common/src/System/TimeProvider.cs b/src/libraries/Common/src/System/TimeProvider.cs index a6e2936516550..9eca00ff0311a 100644 --- a/src/libraries/Common/src/System/TimeProvider.cs +++ b/src/libraries/Common/src/System/TimeProvider.cs @@ -57,6 +57,10 @@ public DateTimeOffset GetLocalNow() #endif // SYSTEM_PRIVATE_CORELIB } TimeSpan offset = zoneInfo.GetUtcOffset(utcDateTime); + if (offset.Ticks is 0) + { + return utcDateTime; + } long localTicks = utcDateTime.Ticks + offset.Ticks; if ((ulong)localTicks > (ulong)s_maxDateTicks)