getTime method

String getTime({
  1. bool is24Hours = false,
})

19:02 or 7:02 pm depending on is24Hours

Implementation

String getTime({bool is24Hours = false}) {
  int hour = is24Hours
      ? this.hour
      : this.hour > 12
          ? this.hour - 12
          : this.hour;
  String suffix = is24Hours
      ? ''
      : this.hour >= 12
          ? ' pm'
          : ' am';

  return '${_getReadableValue(hour)}:${_getReadableValue(this.minute)}'
      '$suffix';
}