All files / src/shared/lib/helpers time.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 142x   2x 11x 11x 11x 11x              
import l10n from "shared/lib/lang/l10n";
 
export const msToHumanTime = (milliseconds: number): string => {
  const totalSeconds = milliseconds / 1000;
  const minutes = Math.floor(totalSeconds / 60);
  const seconds = totalSeconds % 60;
  return minutes > 0
    ? l10n("FIELD_TIME_MINUTES_AND_SECONDS", {
        minutes,
        seconds: Math.floor(seconds),
      })
    : l10n("FIELD_TIME_SECONDS", { seconds: parseFloat(seconds.toFixed(2)) });
};