ceil method

  1. @Possible({RangeError})
  2. @useResult
DateTime ceil(
  1. TemporalUnit unit,
  2. int value
)

Returns a copy of this ceiled to the nearest unit and value.

Contract

Throws RangeError if value <= 0.

Example

DateTime(2023, 4, 15).ceil(DateUnit.months, 6); // 2023-06-01 00:00
DateTime(2023, 8, 15).ceil(DateUnit.months, 6); // 2023-12-01 00:00

Implementation

@Possible({RangeError})
@useResult DateTime ceil(TemporalUnit unit, int value) => _adjust(unit, (date) => date.ceilTo(value));