formatDate static method
Format day display
Implementation
static String formatDate(DateTime dateTime, String format) {
if (format.isEmpty) {
return dateTime.toString();
}
String result = format;
// format year text
if (format.contains('y')) {
result = _formatYear(dateTime.year, result);
}
// format month text
if (format.contains('M')) {
result = _formatMonth(dateTime.month, result);
}
// format day text
if (format.contains('d')) {
result = _formatDay(dateTime.day, result);
}
if (format.contains('E')) {
result = _formatWeek(dateTime.weekday, result);
}
if (result == format) {
return dateTime.toString();
}
return result;
}