formatHour function

String formatHour(
  1. TimeOfDay timeOfDay, {
  2. bool alwaysUse24HourFormat = false,
})

Implementation

String formatHour(TimeOfDay timeOfDay, {bool alwaysUse24HourFormat = false}) {
  final TimeOfDayFormat format =
      timeOfDayFormat(alwaysUse24HourFormat: alwaysUse24HourFormat);
  switch (format) {
    case TimeOfDayFormat.h_colon_mm_space_a:
      return formatDecimal(
          timeOfDay.hourOfPeriod == 0 ? 12 : timeOfDay.hourOfPeriod);
    case TimeOfDayFormat.HH_colon_mm:
      return _formatTwoDigitZeroPad(timeOfDay.hour);
    default:
      throw AssertionError(' does not support $format.');
  }
}