c# - Xamarin TimeZoneInfo.GetUtcOffset 抛出 NotImplementedException

标签 c# xamarin mono

我正在尝试运行这段代码:

_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/

相关文章:

c# - .Net Core 3 IStringLocalizer.WithCulture(CultureInfo) 已过时

c# - 即使在启用 CORS 后,我也无法访问客户端上的 Response.Headers ("Content-Disposition")

macos - Xamarin Monodevelop - 错误 CS0103

c# - Xamarin 中的包安装错误

f# - Mono 编译器中的错误 : Files in libraries or multiple-file applications must begin with a namespace or module declaration

c# - 如何避免 Entity Framework 中硬编码字段名称?

c# - 动态查询的最佳选择?

c# - 未知的解决方案项目类型 : {42C0BBD9-55CE-4FC1-8D90-A7348ABAFB23}

xaml - Xamarin ImageButton 单击后不可见

c# - Android 模拟器没有响应 Xamarin 的 AMD 进程的问题