parseDate function

DateTime parseDate(
  1. String value
)

Parses a date from the given value and returns it as a DateTime.

  • Throws a FormatException if the value is empty or contains an invalid date.

Implementation

DateTime parseDate(String value) {
  if (value.isEmpty) {
    throw const FormatException('Value cannot be empty');
  }
  try {
    return parseHttpDate(value);
  } catch (e) {
    throw const FormatException('Invalid date format');
  }
}