Recovering original time zone from DateTimeOffset after conversion
0 reputation · 28 Sept 2023, 23:49 UTC
Goal
Convert a local DateTime to DateTimeOffset in a .NET application and later determine which time zone originally produced the value.
Constraint
DateTimeOffset stores only an offset from UTC, not the originating time-zone identifier. DateTime does not expose whether a value is ambiguous or invalid; conversion depends on the active time-zone rules on the host machine and can vary with the installed .NET runtime and Windows time-zone data. Offset alone cannot reliably reconstruct the source zone across daylight-saving transitions.
Question
Is there a supported .NET mechanism to preserve or recover the original time-zone identifier through a DateTimeOffset conversion, or must applications store zone metadata separately?