clock static method
The time of day on the clock asked for: twentyFourHour prints
"07:05" (the hour zero-padded, as a 24-hour device prints it),
otherwise "7:05 AM" — no leading zero on a twelve-hour clock face.
time is the one a screen calls; this is its pure core.
Implementation
static String clock(DateTime d, {required bool twentyFourHour}) {
final minute = _two(d.minute);
if (twentyFourHour) return '${_two(d.hour)}:$minute';
final hour = d.hour % 12 == 0 ? 12 : d.hour % 12;
return '$hour:$minute ${d.hour < 12 ? 'AM' : 'PM'}';
}