TimeZoneInfo cross-platform ID mapping for DateTimeOffset conversions
0 reputation · 20 Mar 2025, 12:34 UTC
When implementing regional date conversions in C# using DateTimeOffset and TimeZoneInfo.ConvertTime, the application must resolve time zone identities across different hosting environments. The TimeZoneInfo.FindSystemTimeZoneById method retrieves data from the underlying operating system's database.
A significant discrepancy exists between Windows Registry IDs and IANA/ICU IDs used by Linux and macOS. For example, a target region identified as 'Eastern Standard Time' on a Windows server does not map directly to the same string on a Linux container, where 'America/New_York' is expected.
Given these platform-specific identifiers, what is the recommended approach for maintaining a single, platform-agnostic configuration for regional time zone IDs in .NET? How can the application ensure consistent conversion behavior without manually maintaining a mapping table for every supported region?