toDateTime static method
Converts a dynamic value to a non-nullable DateTime.
d
- The dynamic value to be converted.
def
- The default DateTime value if conversion fails.
unit
- The time unit of the input value (default is seconds).
Returns a DateTime.
Implementation
static DateTime toDateTime(
dynamic d,
DateTime def, {
TimeUnit unit = TimeUnit.seconds,
}) {
return toDateTimeN(d, unit: unit) ?? def;
}