Why the method IsDaylightSavingTime() returns an apparently wrong value for a specific hour range? To be unambiguous i start from a UTC date. The time new DateTime(2016, 10, 30, 0, 59, 0, DateTimeKind.Utc)
is the last minute of DST for WEST. Indeed in WEST it gives 2 hours of offset (2.59 am), while a minute later there is an offset of 1 hour (2.00 am). But then why:
TimeZoneInfo.ConvertTimeFromUtc(
new DateTime(2016, 10, 30, 0, 59, 0, DateTimeKind.Utc),
TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time")
).IsDaylightSavingTime()
returns false?!
This method returns false starting from new DateTime(2016, 10, 30, 0, 0, 0, DateTimeKind.Utc)
(but why?), the second before, new DateTime(2016, 10, 29, 23, 59, 59, DateTimeKind.Utc)
, it returns true.
The TimeZoneInfo methods seems to work:
var thisIsTrue = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time").IsDaylightSavingTime(new DateTime(2016, 10, 30, 0, 0, 0, DateTimeKind.Utc));
var thisIsFalse = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(2016, 10, 30, 0, 0, 0, DateTimeKind.Utc), TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time")).IsDaylightSavingTime();
Casey-obrien is right in his comment. The reason is that once translated into my local timezone, all the hours between 2.00am and 2.59am became ambiguous, since they occur twice: once before the dst ends and once after. That's why the method returns false.
Casey, if you write your comment as answer I will accept it. Thank you.