/// <summary> /// Initializes a new instance of the <see cref="StandardDaylightAlternatingMap"/> class. /// </summary> /// <remarks> /// At least one of the recurrences (it doesn't matter which) must be a "standard", i.e. not have any savings /// applied. The other may still not have any savings (e.g. for America/Resolute) or (for BCL compatibility) may /// even have negative daylight savings. /// </remarks> /// <param name="standardOffset">The standard offset.</param> /// <param name="startRecurrence">The start recurrence.</param> /// <param name="endRecurrence">The end recurrence.</param> internal StandardDaylightAlternatingMap(Offset standardOffset, ZoneRecurrence startRecurrence, ZoneRecurrence endRecurrence) { this.standardOffset = standardOffset; // Treat the recurrences as if they extended to the start of time. startRecurrence = startRecurrence.ToStartOfTime(); endRecurrence = endRecurrence.ToStartOfTime(); Preconditions.CheckArgument(startRecurrence.IsInfinite, nameof(startRecurrence), "Start recurrence must extend to the end of time"); Preconditions.CheckArgument(endRecurrence.IsInfinite, nameof(endRecurrence), "End recurrence must extend to the end of time"); var dst = startRecurrence; var standard = endRecurrence; if (startRecurrence.Savings == Offset.Zero) { dst = endRecurrence; standard = startRecurrence; } Preconditions.CheckArgument(standard.Savings == Offset.Zero, nameof(startRecurrence), "At least one recurrence must not have savings applied"); dstRecurrence = dst; standardRecurrence = standard; }
/// <summary> /// Initializes a new instance of the <see cref="DaylightSavingsDateTimeZone"/> class. /// </summary> /// <remarks> /// At least one of the recurrences (it doesn't matter which) must be a "standard", i.e. not have any savings /// applied. The other may still not have any savings (e.g. for America/Resolute) or (for BCL compatibility) may /// even have negative daylight savings. /// </remarks> /// <param name="id">The id.</param> /// <param name="standardOffset">The standard offset.</param> /// <param name="startRecurrence">The start recurrence.</param> /// <param name="endRecurrence">The end recurrence.</param> internal DaylightSavingsDateTimeZone([NotNull] String id, Offset standardOffset, ZoneRecurrence startRecurrence, ZoneRecurrence endRecurrence) : base(id, false, standardOffset + Offset.Min(startRecurrence.Savings, endRecurrence.Savings), standardOffset + Offset.Max(startRecurrence.Savings, endRecurrence.Savings)) { this.standardOffset = standardOffset; // Treat the recurrences as if they extended to the start of time. startRecurrence = startRecurrence.ToStartOfTime(); endRecurrence = endRecurrence.ToStartOfTime(); Preconditions.CheckArgument(startRecurrence.IsInfinite, nameof(startRecurrence), "Start recurrence must extend to the end of time"); Preconditions.CheckArgument(endRecurrence.IsInfinite, nameof(endRecurrence), "End recurrence must extend to the end of time"); var dst = startRecurrence; var standard = endRecurrence; if (startRecurrence.Savings == Offset.Zero) { dst = endRecurrence; standard = startRecurrence; } Preconditions.CheckArgument(standard.Savings == Offset.Zero, nameof(startRecurrence), "At least one recurrence must not have savings applied"); dstRecurrence = dst; standardRecurrence = standard; }