Get offset minutes from timezone (string) with NodaTime
You need DateTimeZone.GetUtcOffset(Instant)
:
public static int ConvertFromTimeZoneToMinutesOffset(string timeZone, IClock clock)
{
DateTimeZone zone = DateTimeZoneProviders.Tzdb[timeZone];
Offset offset = zone.GetUtcOffset(clock.Now);
return offset.Milliseconds / NodaConstants.MillisecondsPerMinute;
}
You could leave off the IClock
parameter and instead use SystemClock.Instance
in the method, but that leads to code which is harder to test.