formatTime static method

String formatTime(
  1. DateTime time
)

The time of day of time as a record shows it (toString, a log view, the console, twk logs): hours, minutes and seconds, two digits each, and milliseconds, three.

assert(
  LogRecord.formatTime(DateTime(2026, 1, 1, 9, 5, 7, 42)) ==
      '09:05:07.042',
);

Implementation

static String formatTime(DateTime time) {
  String two(int n) => '$n'.padLeft(2, '0');
  return '${two(time.hour)}:${two(time.minute)}:${two(time.second)}.'
      '${'${time.millisecond}'.padLeft(3, '0')}';
}