formatTimeMinSec property

String get formatTimeMinSec

Format time "hr:min:sec" or "hr:min:sec"

Implementation

String get formatTimeMinSec {
  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:" : ""}$minutesStr:$secondsStr';
}