parseDateTime function
Implementation
DateTime? parseDateTime(Object? date, [DateTime? def]) {
if (date == null) return def;
if (date is DateTime) {
return date;
}
if (date is num) {
if (date == 0 && def != null) return def;
return DateTime.fromMillisecondsSinceEpoch(date.toInt());
}
String s;
if (date is String) {
s = date;
} else {
s = date.toString();
}
s = s.trim();
if (s.isEmpty) return def;
return DateTime.parse(s);
}