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.