defaultFormatGapTime function

String defaultFormatGapTime(
  1. DateTime time
)

Implementation

String defaultFormatGapTime(DateTime time) {
  DateTime now = DateTime.now();
  DateTime startOfToday = DateTime(now.year, now.month, now.day);
  String at;
  if (time.isAfter(startOfToday)) {
    at = DateFormat("HH:mm").format(time);
  } else if (time.isAfter(startOfToday.subtract(const Duration(days: 1)))) {
    at = '昨天 ${DateFormat("HH:mm").format(time)}';
  } else {
    at = DateFormat("MM月dd日 HH:mm").format(time);
  }
  return at;
}