clampTo method

  1. @useResult
DateTime clampTo(
  1. DateTime min,
  2. DateTime max
)

Returns this DateTime clamped to min and max.

Implementation

@useResult
DateTime clampTo(DateTime min, DateTime max) {
  if (isBefore(min)) return min;
  if (isAfter(max)) return max;
  return this;
}