Daylight transitions are not correct on Unix.
authorEric Erhardt <eric.erhardt@microsoft.com>
Fri, 15 Jan 2016 17:54:24 +0000 (11:54 -0600)
committerEric Erhardt <eric.erhardt@microsoft.com>
Fri, 15 Jan 2016 17:54:24 +0000 (11:54 -0600)
When checking whether a DateTime is daylight savings time, TimeZoneInfo gets it wrong when the AdjustmentRule spans multiple years. This is because CheckIsDst will adjust the DateTime's Year to be the same as the AdjustmentRule.StartTime.Year. On Unix, this is incorrect because the AdjustmentRules are fixed for the whole time; the offset doesn't change at all during the AdjustmentRule.

This is a fix for the last 2 issues noted in #2185.

src/mscorlib/src/System/TimeZoneInfo.cs

index c83f34d5043388424b775f3111b6521d90615544..c4548f37478b62e869cdd3f29a8dfefb0534f1b9 100644 (file)
@@ -1900,10 +1900,12 @@ namespace System {
         }
 
 
-        static private Boolean CheckIsDst(DateTime startTime, DateTime time, DateTime endTime,bool ignoreYearAdjustment, AdjustmentRule rule) {
+        static private Boolean CheckIsDst(DateTime startTime, DateTime time, DateTime endTime, bool ignoreYearAdjustment, AdjustmentRule rule) {
             Boolean isDst;
 
-            if (!ignoreYearAdjustment) {
+            // NoDaylightTransitions AdjustmentRules should never get their year adjusted since they adjust the offset for the
+            // entire time period - which may be for multiple years
+            if (!ignoreYearAdjustment && !rule.NoDaylightTransitions) {
                 int startTimeYear = startTime.Year;
                 int endTimeYear = endTime.Year;