formatCurrentPrecision method

  1. @override
  2. @protected
bool formatCurrentPrecision(
  1. StringJoiner sj,
  2. int lastPrecision,
  3. int currentPrecision,
  4. double durationMs,
)
override

Return value indicates whether to stop the loop

Implementation

@override
@protected bool formatCurrentPrecision(StringJoiner sj, int lastPrecision, int currentPrecision, double durationMs)
{
  // Show days or hours if at least one, otherwise skip.
  if (currentPrecision >= TimePrecision.HOURS) {
    if (durationMs < currentPrecision) {
      return false; // Skip if not at least 1.
    }
  }

  sj.add( getDurationForPrecision(currentPrecision, durationMs).toString() );

  // Handles all.
  sj.add(" ");
  sj.add( getUnitName(currentPrecision) );
  sj.add(" ");

  return false; // Continue loop.
}