handle method

  1. @override
DateTime? handle(
  1. dynamic value, {
  2. DateTime? defaultValue,
})
override

Implementation

@override
DateTime? handle(value, {DateTime? defaultValue}) {
  if (value is! String) value = value.toString();

  final intValue = IntConverter().handle(value);

  if (intValue != null) {
    return DateTime.fromMillisecondsSinceEpoch(intValue * 1000);
  }

  for (var f in SuperConverter.dateFormats) {
    try {
      return f.parse(value);
    } catch (e) {
      //not available
    }
  }

  try {
    return DateTime.parse(value);
  } catch (e) {
    return defaultValue;
  }
}