What is the most convenient way to create a specific instance of Microsoft.SharePoint.SPTimeZone
as the following one:
SPTimeZone utc = SPRegionalSettings.GlobalTimeZones
.OfType<SPTimeZone>()
.FirstOrDefault(tz => tz.Information.Bias == 0
&& tz.Information.DaylightBias == 0);
Is this hack the best one I can get...
This is in particular a problem for me, since I would like to mock this part of code for unit testing and to force it to always return UTC. The property GlobalTimeZones
seems to depend on HttpContext.Current
or an actual request - a prerequisite I don't have in my Unit Tests...
N.B: I know that there is System.TimeZoneInfo
but a third party assembly forces me into using SPTimeZone ...