formatTimeToHrMinSec property

String get formatTimeToHrMinSec

Format time "$hr hrs $min mins $sec secs"

Implementation

String get formatTimeToHrMinSec {
  if (isNegative) return "$this";
  int hours = (this / 3600).floor();
  int minutes = ((this % 3600) / 60).floor();
  int seconds = (this % 60);

  String hoursStr = (hours % 24).toString().padLeft(2, '0');
  String minutesStr = minutes.toString().padLeft(2, '0');
  String secondsStr = seconds.toString().padLeft(2, '0');

  return '${hours > 0 ? "$hoursStr hrs " : ""}$minutesStr mins $secondsStr secs';
}