我正在尝试运行这段代码:
_deviceTimeZone.GetUtcOffset(systemNow.ToDateTimeOffset()).TotalMilliseconds
但是有一个异常(exception)
Unhandled Exception: System.NotImplementedException: The method or operation is not implemented. at System.TimeZoneInfo.GetUtcOffset (DateTimeOffset dateTimeOffset) [0x00000] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/mcs/class/corlib/System/TimeZoneInfo.cs:669
我找到带有 GetUtcOffset 和 NotImplementedException 的单声道源:mono github .
如果 TimeZoneInfo 无法执行此操作,我如何获取我的时区的 utc 偏移量?
固定:PR
最佳答案
mono 似乎确实实现了 GetUtcOffset(DateTime dateTime)
。那么,为什么不直接使用它呢:
_deviceTimeZone.GetUtcOffset(systemNow.ToDateTimeOffset().DateTime).TotalMilliseconds;
关于c# - Xamarin TimeZoneInfo.GetUtcOffset 抛出 NotImplementedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35403803/