toStringDateTime method

String toStringDateTime()

Implementation

String toStringDateTime() {
  final dateTime = this;

  if (dateTime == null) {
    return '';
  }

  final amPm = dateTime.hour < 12 ? 'am' : 'pm';
  int hour = dateTime.hour % 12;
  if (hour == 0) hour = 12;

  final day = dateTime.day.addLeftPad();
  final month = dateTime.month.addLeftPad();
  final year = dateTime.year;

  final min = dateTime.minute.addLeftPad();
  final sec = dateTime.second.addLeftPad();

  return '$day/$month/$year ${hour.addLeftPad()}:$min:$sec $amPm';
}