Description
I have detected a case where TimeZoneInfo.ConvertTime returns different results for .NET 10 and for .NET 11 (checked Preview 3 also). The issue takes place for date-time conversions that are close to DateTime.MinValue (e.g. when converting new DateTime(0001, 01, 01, 1, 13, 15) from UTC+4 to UTC+3). For .NET 11 the result seems to be wrong.
I guess the origin of the issue is related to TimeZone Improvements for .NET 11.
Reproduction Steps
- set 2 time zones and some
DateTime close to DateTime.MinValue (The date and time must be such that when converted to UTC, the date must change the era to BC);
- note that this
DateTime is valid in source time zone and will be valid (still in AD era) after conversion to time zone 2;
- try to convert this
DateTime from one time zone to another.
- for .NET 10 result conversion will be correct;
- for .NET 11 result conversion will be incorrect and equal to
MinValue + time zone shift.
The simple example below represents the behavior:
TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Mauritius Standard Time"); // UTC+4
TimeZoneInfo destinationTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Arabic Standard Time"); // UTC+3
DateTime earlyDate = new DateTime(0001, 01, 01, 1, 13, 15);
DateTime converted = TimeZoneInfo.ConvertTime(earlyDate, sourceTimeZone, destinationTimeZone); // .NET 11: {1/1/0001 3:00:00 AM}
// .NET 10: {1/1/0001 12:13:15 AM}
Expected behavior
Conversion result of new DateTime(0001, 01, 01, 1, 13, 15) from UTC+4 to UTC+3 for .NET 11 should be equal to {1/1/0001 12:13:15 AM}
Actual behavior
Actual conversion result is {1/1/0001 3:00:00 AM} for .NET 11
Regression?
In .NET 10 conversion result was correct.
Known Workarounds
No response
Configuration
No response
Other information
No response
Description
I have detected a case where
TimeZoneInfo.ConvertTimereturns different results for .NET 10 and for .NET 11 (checked Preview 3 also). The issue takes place for date-time conversions that are close toDateTime.MinValue(e.g. when convertingnew DateTime(0001, 01, 01, 1, 13, 15)from UTC+4 to UTC+3). For .NET 11 the result seems to be wrong.I guess the origin of the issue is related to TimeZone Improvements for .NET 11.
Reproduction Steps
DateTimeclose toDateTime.MinValue(The date and time must be such that when converted to UTC, the date must change the era to BC);DateTimeis valid in source time zone and will be valid (still in AD era) after conversion to time zone 2;DateTimefrom one time zone to another.MinValue+ time zone shift.The simple example below represents the behavior:
Expected behavior
Conversion result of
new DateTime(0001, 01, 01, 1, 13, 15)from UTC+4 to UTC+3 for .NET 11 should be equal to {1/1/0001 12:13:15 AM}Actual behavior
Actual conversion result is {1/1/0001 3:00:00 AM} for .NET 11
Regression?
In .NET 10 conversion result was correct.
Known Workarounds
No response
Configuration
No response
Other information
No response