getTime method

String getTime(
  1. DateTime time
)

Implementation

String getTime(DateTime time) {
  String threeDigits(int n) {
    if (n >= 100) return '$n';
    if (n >= 10) return '0$n';
    return '00$n';
  }

  String twoDigits(int n) {
    if (n >= 10) return '$n';
    return '0$n';
  }

  var now = time;
  var h = twoDigits(now.hour);
  var min = twoDigits(now.minute);
  var sec = twoDigits(now.second);
  var ms = threeDigits(now.millisecond);
  var timeSinceStart = now.difference(_startTime!).toString();
  return '$h:$min:$sec.$ms (+$timeSinceStart)';
}