toHumanTime method

String toHumanTime()

Implementation

String toHumanTime() {
  if (this! <= 0) return "0 sec";

  int totalSeconds = this! ~/ 1000; // Convert milliseconds to seconds
  int hours = totalSeconds ~/ 3600;
  int minutes = (totalSeconds % 3600) ~/ 60;
  int seconds = totalSeconds % 60;

  List<String> parts = [];

  if (hours > 0) parts.add('$hours ${hours == 1 ? "hour" : "hours"}');
  if (minutes > 0) parts.add('$minutes ${minutes == 1 ? "min" : "min"}');
  if (seconds > 0 && hours == 0) {
    parts.add('$seconds ${seconds == 1 ? "sec" : "sec"}');
  }

  return parts.join(' ');
}