Cross‑platform DateTime Kind.Unspecified conversion with TimeZoneInfo
0 reputation · 18 Jan 2024, 14:27 UTC
Goal: Obtain the same instant‑to‑zone conversion result when a DateTime value with Kind.Unspecified is passed to TimeZoneInfo.ConvertTime on both Windows and Linux.
Constraint: The current implementation treats Unspecified as the local time zone of the process, which can produce different offsets if the value actually represents UTC, especially in cloud‑native scenarios where the input originates from UTC‑based logs.
Uncertainty: Whether .NET Core should change the default assumption to UTC, provide an explicit Kind parameter, or retain the existing local‑time behavior for backward compatibility.
Questions: Should TimeZoneInfo.ConvertTime interpret Unspecified DateTime as UTC by default? Would adding an overload that accepts a DateTimeKind parameter resolve the ambiguity without breaking existing code? Should the documentation be updated to clarify the current assumption and recommend using DateTimeOffset or specifying Kind?