parseDateTime function
Provides a parseDateTime() function that parses a date string to a DateTime object.
string String -> DateTime
Example
var date = parseDateTime("2022-01-01");
print(date is DateTime); // true
print("Date: $date");
Implementation
DateTime parseDateTime(List args) {
_arityCheck(1, args.length);
_stringTypeCheck(args[0]);
try {
return DateTime.parse(args[0] as String);
} catch (_) {
throw RuntimeError("parseDateTime: Invalid date string: ${args[0]}");
}
}