roundedToScale method

FdcTime roundedToScale(
  1. int scale
)

Returns this time rounded to fractional-second scale precision.

Implementation

FdcTime roundedToScale(int scale) {
  _checkRange(scale, 0, 7, 'scale');

  final divisor = _scaleDivisor(scale);
  if (divisor == 1) {
    return this;
  }

  final roundedTicks = _roundToNearestTick(ticksSinceMidnight, divisor);
  return FdcTime._(
    roundedTicks >= ticksPerDay ? ticksPerDay - 1 : roundedTicks,
  );
}