admin管理员组文章数量:1386872
I've figured out that depending on the operating system a .NET application is running on,the following code may have different outputs:
using System.Globalization;
var zone = TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time");
var date = new DateTimeOffset( // Farvardin 1st 1367
year: 1988,
month:3,
day: 21,0, 0, 0, TimeSpan.FromHours(4.5));
var offset = zone.GetUtcOffset(date);
Console.WriteLine(offset);
// On windows prints: 4:30
// On ubuntu prints: 3:30
I know that the difference is because Linux uses IANA timezone database whereas Windows has another database and .NET uses the database provided by OS. I want my app to use IANA time zone database instead of the one provided by default by windows. How can I achieve this?
I'm not looking to convert timezone Identifiers used by IANA and .NET, as described here: How to translate between Windows and IANA time zones?
I know that NodaTime
provides IANA TZDB, however adding a big library just for this purpose, seems like not the best solution.
本文标签: How to use IANA timezone database in NET app running on windowsStack Overflow
版权声明:本文标题:How to use IANA timezone database in .NET app running on windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744573383a2613473.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论