Fix Buggy code in TimeZoneInfo (dotnet/coreclr#27591)
authorTarek Mahmoud Sayed <tarekms@microsoft.com>
Sun, 3 Nov 2019 18:42:33 +0000 (10:42 -0800)
committerGitHub <noreply@github.com>
Sun, 3 Nov 2019 18:42:33 +0000 (10:42 -0800)
Although couldn’t reach the corner case cause executing the buggy code, the fix here is done according to the similar code in TimeZoneInfo which show the intention of the change

https://github.com/dotnet/coreclr/blob/dotnet/coreclr@97c582975eed3260ef21e0bcc55c8c86d1e3bec8/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs#L1638
https://github.com/dotnet/coreclr/blob/dotnet/coreclr@97c582975eed3260ef21e0bcc55c8c86d1e3bec8/src/System.Private.CoreLib/shared/System/TimeZoneInfo.cs#L1568

Commit migrated from https://github.com/dotnet/coreclr/commit/cdb2f6a4a356db55861c35e5dcb2cde8c76a2ea9

src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs

index 1d9cb5f..8e04fd2 100644 (file)
@@ -1459,7 +1459,7 @@ namespace System
                     {
                         ambiguousStartModified = ambiguousStart.AddYears(1);
                         ambiguousEndModified = ambiguousEnd.AddYears(1);
-                        isAmbiguousLocalDst = (time >= ambiguousStart && time < ambiguousEnd);
+                        isAmbiguousLocalDst = (time >= ambiguousStartModified && time < ambiguousEndModified);
                     }
                     catch (ArgumentOutOfRangeException) { }
 
@@ -1469,7 +1469,7 @@ namespace System
                         {
                             ambiguousStartModified = ambiguousStart.AddYears(-1);
                             ambiguousEndModified = ambiguousEnd.AddYears(-1);
-                            isAmbiguousLocalDst = (time >= ambiguousStart && time < ambiguousEnd);
+                            isAmbiguousLocalDst = (time >= ambiguousStartModified && time < ambiguousEndModified);
                         }
                         catch (ArgumentOutOfRangeException) { }
                     }