/// <summary> /// Sets the RockDateTime timezone to a value that is suitable for testing an operating environment /// in which the organization timezone does not match the local system timezone. /// This configuration simulates a Rock server hosted in a different timezone to the Rock organization. /// </summary> public static void SetRockDateTimeToAlternateTimezone() { var tz = GetTestTimeZoneAlternate(); RockDateTime.Initialize(tz); // Re-initialize the lava engine options. var options = GetCurrentEngineOptions(); _fluidEngine.Initialize(options); }
/// <summary> /// Sets the RockDateTime timezone to a value that is suitable for testing an operating environment /// in which the organization timezone supports daylight saving time. /// </summary> public static void SetRockDateTimeToDaylightSavingTimezone() { // Set to Mountain Standard Time (MST), a timezone that supports Daylight Saving Time (DST). var tz = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time"); Assert.That.IsNotNull(tz, "Timezone 'MST' is not available in this environment."); Assert.That.IsTrue(tz.SupportsDaylightSavingTime, "Test Timezone should be configured for Daylight Saving Time (DST)."); RockDateTime.Initialize(tz); // Re-initialize the lava engine options. var options = GetCurrentEngineOptions(); _fluidEngine.Initialize(options); }
/// <summary> /// Sets the RockDateTime timezone to a value that is suitable for testing an operating environment /// in which the organization timezone does not match the local system timezone. /// This configuration simulates a Rock server hosted in a different timezone to the Rock organization. /// </summary> public static void SetRockOrganizationTimeZone(string timeZoneId) { try { var tz = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); RockDateTime.Initialize(tz); } catch (TimeZoneNotFoundException) { throw new Exception($"Timezone '{timeZoneId}' is not available in this environment."); } // Re-initialize the lava engine options. var options = GetCurrentEngineOptions(); _fluidEngine.Initialize(options); }
/// <summary> /// Initializes the Rock organization time zone. /// </summary> private static void InitializeRockOrgTimeZone() { string orgTimeZoneSetting = ConfigurationManager.AppSettings["OrgTimeZone"]; if (string.IsNullOrWhiteSpace(orgTimeZoneSetting)) { RockDateTime.Initialize(TimeZoneInfo.Local); } else { // if Web.Config has the OrgTimeZone set to the special "Local" (intended for Developer Mode), just use the Local DateTime. However, a production install of Rock will always have a real Time Zone string if (orgTimeZoneSetting.Equals("Local", StringComparison.OrdinalIgnoreCase)) { RockDateTime.Initialize(TimeZoneInfo.Local); } else { RockDateTime.Initialize(TimeZoneInfo.FindSystemTimeZoneById(orgTimeZoneSetting)); } } }
/// <summary> /// Sets the RockDateTime timezone to the current system local timezone. /// </summary> public static void SetRockOrganizationLocalTimeZone() { RockDateTime.Initialize(TimeZoneInfo.Local); }
/// <summary> /// Sets the RockDateTime timezone to the current system local timezone. /// </summary> public static void SetRockDateTimeToLocalTimezone() { RockDateTime.Initialize(TimeZoneInfo.Local); }