Description
The System.Management.ManagementDateTimeConverter.ToDateTime
method is setting DateTimeKind.Unspecified
in the result here.
I believe this to be incorrect, as it explicitly adjusts the time to the local computer's offset. As a user of this API, I'd expect the resulting DateTime
value's Kind
property to be DateTimeKind.Local
.
With unspecified kind, I'd expect the result to not have been adjusted to the local time zone.
Also, a couple of other observations about the ManagementDateTimeConverter
class:
-
The fixes from May 2018 seen in the history don't appear to have been ported back to .NET Framework. For example, I can see that in the NetFX implementation it still uses
TimeZone.CurrentTimeZone
instead ofTimeZoneInfo.Local
. -
It would seem prudent to make a
ToDateTimeOffset
method that retains the offset provided in the DMTF string. Otherwise the user has to go out of their way to parse the string again manually to obtain the original offset. -
Likewise, it would seem prudent to have an overload of
ToDMTFDateTime
that accepts aDateTimeOffset
. Otherwise, there's no capability to create a DMTF string that has anything other than the local offset or zero.