/// <summary> /// Initializes a new instance of the <see cref="LegacyAvailabilityTimeZoneTime"/> class. /// </summary> /// <param name="transitionTime">The transition time used to initialize this instance.</param> /// <param name="delta">The offset used to initialize this instance.</param> LegacyAvailabilityTimeZoneTime(TimeZoneInfo.TransitionTime transitionTime, TimeSpan delta) : this() { this.delta = delta; if (transitionTime.IsFixedDateRule) { // TimeZoneInfo doesn't support an actual year. Fixed date transitions occur at the same // date every year the adjustment rule the transition belongs to applies. The best thing // we can do here is use the current year. this.year = DateTime.Today.Year; this.month = transitionTime.Month; this.dayOrder = transitionTime.Day; this.timeOfDay = transitionTime.TimeOfDay.TimeOfDay; } else { // For floating rules, the mapping is direct. this.year = 0; this.month = transitionTime.Month; this.dayOfTheWeek = EwsUtilities.SystemToEwsDayOfTheWeek(transitionTime.DayOfWeek); this.dayOrder = transitionTime.Week; this.timeOfDay = transitionTime.TimeOfDay.TimeOfDay; } }
/// <summary> /// Initializes this transition based on the specified transition time. /// </summary> /// <param name="transitionTime">The transition time to initialize from.</param> internal override void InitializeFromTransitionTime(TimeZoneInfo.TransitionTime transitionTime) { base.InitializeFromTransitionTime(transitionTime); this.dayOfTheWeek = EwsUtilities.SystemToEwsDayOfTheWeek(transitionTime.DayOfWeek); // TimeZoneInfo uses week indices from 1 to 5, 5 being the last week of the month. // EWS uses -1 to denote the last week of the month. this.weekIndex = transitionTime.Week == 5 ? -1 : transitionTime.Week; }