formatTime method

String formatTime(
  1. DateTime date,
  2. bool diffToNow, {
  3. String? format,
})

Method to build a String representing the Time part of a DateTime

Implementation

String formatTime(DateTime date, bool diffToNow, {String? format}) {
  if (!diffToNow) {
    format ??= Strings.get("_time_format_", fallbackValue: null);
  }
  if (format != null) {
    return DateFormat(format).format(date.toLocal());
  }

  return DateFormat(Strings.get("_time_format_", fallbackValue: null))
      .format(date.toLocal());
}