Skip to content

Commit

Permalink
TimeProvider GetLocalNow enhancement (#90066)
Browse files Browse the repository at this point in the history
Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>
  • Loading branch information
WeihanLi and tarekgh authored Aug 6, 2023
1 parent 3f566cd commit 7a94213
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libraries/Common/src/System/TimeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7a94213

Please sign in to comment.