I wrote several tests for converting times from a specific timezone to UTC.
The rules say that in Europe the clocks are shifted forward at 01:00 UTC, for 'GTB Standard Time' this means +2 UTC, e.g. 03:00:00 .
However, I discovered that there are discrepancies in tests for different platforms (Linux vs Windows) using TimeZoneInfo.IsDaylightSavingTime(dateTime) method.
I created a new test object for DST transition date and time:
var testDate = new DateTime(2019, 03, 31, 03, 20, 00); //20 minutes after Daylight Saving Time start
...
And passed it in for TimeZoneInfo 'timeZone' object, where time zone was set to 'GTB Standard Time':
...
var timeZone = TimeZoneInfo.FindSystemTimeZoneById("GTB Standard Time");
return timeZone.IsDaylightSavingTime(testDate);
}
This returns False, although 03:20:00 locally on 2019-03-31 the daylight saving should already be ON. This should have returned True.
I managed to repeat this test only on Windows using built-in database for .Net timezones. With tzdata db (NodaTime for example) returns True for this test.
Confusing part was that I manually threw an error for the timeZone object to see what extra information comes from TimeZoneInfo object and found that DST start is actually correct:
timeZone.GetAdjustmentRules().First().DaylightTransitionStart.TimeOfDay
returns 03:00:00
Could someone confirm this and also is there a way to check where does windows take DST times? Can I make current test pass on both windows and linux without using any external libraries?
Aucun commentaire:
Enregistrer un commentaire