System.TimeZoneInfo.FindSystemTimeZoneById return wrong time zone info for the following IANA ids: "America/Ojinaga", "America/Chihuahua", "America/Ciudad_Juarez"
Reproduction Steps
namespace ConsoleAppTest {
internal class Program {
static void Main(string[] args) {
Console.WriteLine($"-- {GetTimeZone("America/Matamoros")}");
Console.WriteLine($"-- {GetTimeZone("America/Ojinaga")}");
Console.WriteLine($"-- {GetTimeZone("America/Monterrey")}");
Console.WriteLine($"-- {GetTimeZone("America/Mexico_City")}");
Console.WriteLine($"-- {GetTimeZone("America/Chihuahua")}");
Console.WriteLine($"-- {GetTimeZone("America/Bahia_Banderas")}");
Console.WriteLine($"-- {GetTimeZone("America/Merida")}");
Console.WriteLine($"-- {GetTimeZone("America/Cancun")}");
try {
Console.WriteLine($"-- {GetTimeZone("America/Ciudad_Juarez")}"); //New Zone
} catch (Exception e) { Console.WriteLine($"-- {e}"); }
Console.WriteLine($"-- {GetTimeZone("America/Mazatlan")}");
Console.WriteLine($"-- {GetTimeZone("America/Tijuana")}");
Console.WriteLine($"-- {GetTimeZone("America/Hermosillo")}");
}
public static string GetTimeZone(string id) {
const string dateFormat = "yyyy/MM/dd HH:mm";
DateTime currentDateUTC = System.DateTime.UtcNow;
var timeZoneInfo = System.TimeZoneInfo.FindSystemTimeZoneById(id);
DateTime currentDateTimeZone = System.TimeZoneInfo.ConvertTimeFromUtc(currentDateUTC, timeZoneInfo);
return $"currentDateUTC:{currentDateUTC.ToString(dateFormat)}, currentDateTimeZone:{currentDateTimeZone.ToString(dateFormat)}, TimeZoneIdentifier:{timeZoneInfo.Id}, WindowsTimeZoneId:{GetWindowsTimeZoneId(id)}, IsDaylightSavingTime:{timeZoneInfo.IsDaylightSavingTime(currentDateTimeZone)}, BaseUtcOffset:{timeZoneInfo.BaseUtcOffset}, TimeZoneUtcOffset:{timeZoneInfo.GetUtcOffset(currentDateUTC)}";
}
public static string GetWindowsTimeZoneId(string ianaid) {
if (System.TimeZoneInfo.TryConvertIanaIdToWindowsId(ianaid, out string? winId)) {
return winId;
}
throw new System.TimeZoneNotFoundException($"No Windows time zone found for IANA Id {ianaid}.");
}
}
}
Expected behavior
System.TimeZoneInfo.FindSystemTimeZoneById("America/Ojinaga") should return time zone info for Windows Time Zone "Central Standard Time"
System.TimeZoneInfo.FindSystemTimeZoneById("America/Chihuahua") should return time zone info for Windows Time Zone "Central Standard Time (Mexico)"
System.TimeZoneInfo.FindSystemTimeZoneById("America/Ciudad_Juarez") should return time zone info for Windows Time Zone "Mountain Standard Time"
Actual behavior
System.TimeZoneInfo.FindSystemTimeZoneById("America/Ojinaga") return time zone info for Windows Time Zone "Mountain Standard Time"
System.TimeZoneInfo.FindSystemTimeZoneById("America/Chihuahua") return time zone info for Windows Time Zone "Mountain Standard Time (Mexico)"
System.TimeZoneInfo.FindSystemTimeZoneById("America/Ciudad_Juarez") throws System.TimeZoneNotFoundException: The time zone ID 'America/Ciudad_Juarez' was not found on the local computer.
Regression?
No response
Known Workarounds
No response
Configuration
Which version of .NET is the code running on?: .NET 8
What OS and version, and what distro if applicable?: Windows 11 Pro 22631.3296
What is the architecture (x64, x86, ARM, ARM64)?: x64
Description
October 26th, 2022, order from the Mexican Government, changes in time zones. https://techcommunity.microsoft.com/t5/daylight-saving-time-time-zone/mexico-2023-time-zone-updates-now-available/ba-p/3749684
System.TimeZoneInfo.FindSystemTimeZoneById return wrong time zone info for the following IANA ids: "America/Ojinaga", "America/Chihuahua", "America/Ciudad_Juarez"
Reproduction Steps
Expected behavior
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response