fromYYYYMMDDtoDDTHMMMYYYY method

String fromYYYYMMDDtoDDTHMMMYYYY({
  1. bool showYear = true,
})

from 2023-12-04 to 4th Dec, 2023

Implementation

String fromYYYYMMDDtoDDTHMMMYYYY({bool showYear = true}) {
  final dateString = this;
  final dateList = dateString.split('-').reversed;
  if (dateList.length == 3) {
    if (showYear) {
      return '${toNumberText(int.parse(dateList.first))} ${getShortMonthText(int.parse(dateList.elementAt(1)))}, ${dateList.last}';
    }
    return '${toNumberText(int.parse(dateList.first))} ${getShortMonthText(int.parse(dateList.elementAt(1)))}';
  }
  return dateString;
}