floor method

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

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

Contract

Throws RangeError if value <= 0.

Example

final foo = ZonedDateTime('Asia/Singapore', 2023, 4, 15);
foo.floor(DateUnit.months, 6); // 2023-01-01T00:00+08:00[Asia/Singapore]

final bar = ZonedDateTime('Asia/Singapore', 2023, 8, 15);
bar.floor(DateUnit.months, 6); // 2023-06-01T00:00+08:00[Asia/Singapore]

Implementation

@Possible({RangeError})
@useResult ZonedDateTime floor(TemporalUnit unit, int value) => ZonedDateTime._convert(timezone, _native.floor(unit, value));