public void InflateByYears(int value) { if (value > 0) { /* * steps is positive * decrease min, increase max by the amount of steps */ if (Minimum.TryAddYears(-value.NotBelow((int)(Bounds.Minimum - Minimum).Years()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddYears(value.NotAbove((int)(Bounds.Maximum - Maximum).Years()), out DateTime dtx)) { Maximum = dtx; } } else if (value < 0) { /* * steps is negative * increase min, decrease max by the amount of steps */ if (Minimum.TryAddYears(-value.NotAbove((int)(Bounds.Maximum - Minimum).Years()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddYears(value.NotBelow((int)(Bounds.Minimum - Maximum).Years()), out DateTime dtx)) { Maximum = dtx; } } }
public void ShiftByYears(int value) { if (value > 0) { /* * steps is positive * increase min, max by the amount of steps only * if they will be less than or equal bounds max */ if (Minimum.TryAddYears(value.NotAbove((int)(Bounds.Maximum - Minimum).Years()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddYears(value.NotAbove((int)(Bounds.Minimum - Maximum).Years()), out DateTime dtx)) { Maximum = dtx; } } else if (value < 0) { /* * steps is negative * decrease min, max by the amount of steps only * if they will be greater than or equal bounds min */ // This is not a mistake, I'll actually add a negative to a negative if (Minimum.TryAddYears(value.NotBelow((int)(Bounds.Minimum - Minimum).Years()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddYears(value.NotBelow((int)(Bounds.Minimum - Maximum).Years()), out DateTime dtx)) { Maximum = dtx; } } }