I'm trying to calculate the correct DST offset for the point in time when the UK switches to BST which should be at 1am on 2021-03-28.
I have a fiddle here: https://dotnetfiddle.net/8gdVIG
For completeness, this is the code I'm running:
var timeZoneInfo = TimeZoneInfo.GetSystemTimeZones().FirstOrDefault(tzi => tzi.Id.Equals("Europe/London", StringComparison.InvariantCultureIgnoreCase));
Console.WriteLine($"No. of adjustment rules: {timeZoneInfo.GetAdjustmentRules().Count()}");
var firstRule = timeZoneInfo.GetAdjustmentRules().FirstOrDefault(r => new DateTime(2021,03,28,1,59,0) >= r.DateStart && new DateTime(2021,03,28,1,59,0) <= r.DateEnd);
Console.WriteLine($" Day: {firstRule.DaylightTransitionStart.Day}");
Console.WriteLine($" DayOfWeek: {firstRule.DaylightTransitionStart.DayOfWeek}");
Console.WriteLine($"IsFixedDateRule: {firstRule.DaylightTransitionStart.IsFixedDateRule}");
Console.WriteLine($" Month: {firstRule.DaylightTransitionStart.Month}");
Console.WriteLine($" TimeOfDay: {firstRule.DaylightTransitionStart.TimeOfDay}");
Console.WriteLine($" Week: {firstRule.DaylightTransitionStart.Week}");
Console.WriteLine($"Offset at 01:59 on 2021-03-28: {timeZoneInfo.GetUtcOffset(new DateTime(2021,03,28,1,59,0)).Hours}");
The results of which are:
No. of adjustment rules: 244
Day: 28
DayOfWeek: Sunday
IsFixedDateRule: True
Month: 3
TimeOfDay: 01/01/0001 01:00:00
Week: 1
Offset at 01:59 on 2021-03-28: 0
And yet the offset at 2am is the 1 hour I expect at 1am.
Console.WriteLine($"Offset at 02:00 on 2021-03-28: {timeZoneInfo.GetUtcOffset(new DateTime(2021,03,28,2,0,0)).Hours}");
Output:
Offset at 02:00 on 2021-03-28: 1
Why is the UTC offset not 1 hour at 1am? Do I really need Noda Time just to get the correct local DST offset?