更新时间:2023-01-28 10:42:04
感谢澄清你的问题。
如果一个DateTime实例类
是本地
,那么 TimeZoneInfo.ConvertTime
将期望的第二个参数是你的计算机的本地时区
If the DateTime instance Kind
is Local
, then TimeZoneInfo.ConvertTime
will expect the second parameter to be the local timezone of your computer.
如果DateTime的实例类
是 UTC
,然后 TimeZoneInfo.ConvertTime
会期望是UTC时区的第二个参数。
If DateTime instance Kind
is Utc
, then TimeZoneInfo.ConvertTime
will expect the second parameter to be the Utc timezone.
您需要outageEndDate转换为正确的时区第一,以防万一localProvice时区不匹配您的计算机上的时区。
You need to convert outageEndDate to the right timezone first, just in case the localProvice timezone doesn't match the timezone on your computer.
outageEndDate = TimeZoneInfo.ConvertTime(outageEndDate, localTime);