public void InflateByHours(int value) { if (value > 0) { /* * steps is positive * decrease min, increase max by the amount of steps */ if (Minimum.TryAddHours(-value.NotBelow((int)(Bounds.Minimum - Minimum).Hours()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddHours(value.NotAbove((int)(Bounds.Maximum - Maximum).Hours()), out DateTime dtx)) { Maximum = dtx; } } else if (value < 0) { /* * steps is negative * increase min, decrease max by the amount of steps */ if (Minimum.TryAddHours(-value.NotAbove((int)(Bounds.Maximum - Minimum).Hours()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddHours(value.NotBelow((int)(Bounds.Minimum - Maximum).Hours()), out DateTime dtx)) { Maximum = dtx; } } }
public void ShiftByHours(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.TryAddHours(value.NotAbove((int)(Bounds.Maximum - Minimum).Hours()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddHours(value.NotAbove((int)(Bounds.Maximum - Maximum).Hours()), 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.TryAddHours(value.NotBelow((int)(Bounds.Minimum - Minimum).Hours()), out DateTime dtn)) { Minimum = dtn; } if (Maximum.TryAddHours(value.NotBelow((int)(Bounds.Minimum - Maximum).Hours()), out DateTime dtx)) { Maximum = dtx; } } }