-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
In .NET 11 Preview 1, the behavior of TimeZoneInfo.GetUtcOffset appears to have changed when called with an invalid DateTime. I would like to know whether this change is intentional or a regression.
For example, Paraguay used UTC-4 before switching permanently to UTC-3. In its TimeZoneInfo.GetAdjustmentRules(), all the rules contain BaseUtcOffsetDelta == -01:00.
In .NET 10, calling GetUtcOffset(new DateTime(2023, 10, 6, 0, 0, 0)) (the specified time here is invalid), returned the standard time offset for that year, which is -04:00. That means the BaseUtcOffsetDelta was taken into account.
However, in .NET 11 Preview 1, the same call returns -03:00, which corresponds to the current BaseUtcOffset without applying BaseUtcOffsetDelta for the year of 2023.
Could you confirm whether this small behavioral change is expected?
Reproduction Steps
using System;
public class Program {
public static void Main() {
var paraguayTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Paraguay Standard Time");
var invalidDateTime = new DateTime(2023, 10, 6, 0, 0, 0);
var utcOffset = paraguayTimeZone.GetUtcOffset(invalidDateTime);
Console.WriteLine($"UtcOffset: {utcOffset}");
}
}Expected behavior
Base offset for the year of 2023 is printed (.NET 10 behavior):
UtcOffset: -04:00:00
Actual behavior
Current base offset is printed (.NET 11 behavior):
UtcOffset: -03:00:00
Regression?
No response
Known Workarounds
No response
Configuration
OS: Windows 11
.NET version: .NET 11 Preview 1
Other information
No response