round method

  1. @Possible({RangeError})
  2. @useResult
LocalDate round(
  1. DateUnit unit,
  2. int value
)

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

Contract

Throws a RangeError if value <= 0.

Example

LocalDate(2023, 4, 15).round(DateUnit.months, 6); // 2023-06-01

LocalDate(2023, 8, 15).round(DateUnit.months, 6); // 2023-06-01

Implementation

@Possible({RangeError})
@useResult LocalDate round(DateUnit unit, int value) => LocalDate._(_native.round(unit, value));