getDatetimeOrNull method

DateTime? getDatetimeOrNull()

Implementation

DateTime? getDatetimeOrNull() {
  final value = getValueOrNull();
  if (value == null) return null;

  final sql = DateTime.tryParse(value);
  if (sql != null) return sql;

  try {
    return formatoPeru.parse(value);
  } catch (_) {}

  final time = _parseInternalTime(value);
  if (time != null) {
    final now = DateTime.now();
    return DateTime(now.year, now.month, now.day, time.hour, time.minute);
  }

  return null;
}