formatDateTime function
Implementation
String formatDateTime(String fmt, DateTime dt) {
if (fmt == 'c' || fmt.isEmpty) {
final d = '${dt.year}-${_dtPad2(dt.month)}-${_dtPad2(dt.day)}';
if (dt.hour == 0 && dt.minute == 0 && dt.second == 0) return d;
return '$d ${_dtPad2(dt.hour)}:${_dtPad2(dt.minute)}:${_dtPad2(dt.second)}';
}
return fmt
.replaceAll("yyyy", dt.year.toString().padLeft(4, "0"))
.replaceAll("yy", _dtPad2(dt.year % 100))
.replaceAll("mm", _dtPad2(dt.month))
.replaceAll("dd", _dtPad2(dt.day))
.replaceAll("hh", _dtPad2(dt.hour))
.replaceAll("nn", _dtPad2(dt.minute))
.replaceAll("ss", _dtPad2(dt.second));
}