Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes TimeZoneInfo.GetDaylightChanges #32722. #2022

Merged
merged 2 commits into from
Sep 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions mcs/class/corlib/System/TimeZoneInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -930,12 +930,12 @@ internal DaylightTime GetDaylightChanges (int year)
}

// DaylightTime.Start is relative to the Standard time.
if (start != DateTime.MinValue)
start += BaseUtcOffset;
if (!TryAddTicks (start, BaseUtcOffset.Ticks, out start))
start = DateTime.MinValue;

// DaylightTime.End is relative to the DST time.
if (end != DateTime.MinValue)
end += BaseUtcOffset + delta;
if (!TryAddTicks (end, BaseUtcOffset.Ticks + delta.Ticks, out end))
end = DateTime.MinValue;
} else {
AdjustmentRule first = null, last = null;

Expand Down
13 changes: 13 additions & 0 deletions mcs/class/corlib/Test/System/TimeZoneInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,19 @@ public void TestSydneyDaylightChanges ()
Assert.AreEqual (new DateTime (2014, 10, 5, 2, 0, 0), changes.Start);
Assert.AreEqual (new DateTime (2014, 4, 6, 3, 0, 0), changes.End);
}

[Test]
public void AllTimeZonesDaylightChanges ()
{
foreach (var tz in TimeZoneInfo.GetSystemTimeZones ()) {
try {
for (var year = 1950; year <= DateTime.Now.Year; year++)
getChanges.Invoke (tz, new object [] {year} );
} catch (Exception e) {
Assert.Fail ("TimeZone " + tz.Id + " exception: " + e.ToString ());
}
}
}
}
}
}