isBefore function
check if the string is a date that's before the specified date
If date is not passed, it defaults to now.
Implementation
bool isBefore(String str, [date]) {
if (date == null) {
date = DateTime.now();
} else if (isDate(date)) {
date = DateTime.parse(date);
} else {
return false;
}
DateTime strDate;
try {
strDate = DateTime.parse(str);
} catch (e) {
return false;
}
return strDate.isBefore(date);
}