extractHeaderDateTimeValue function

DateTime? extractHeaderDateTimeValue(
  1. Map<String, String> headers,
  2. String name, {
  3. DateTime? parser(
    1. String
    )?,
})

Implementation

DateTime? extractHeaderDateTimeValue(Map<String, String> headers, String name,
    {DateTime? Function(String)? parser}) {
  final v = extractHeaderStringValue(headers, name);

  if (v == null) {
    return null;
  }

  if (parser != null) {
    return parser(v);
  }

  return DateTime.tryParse(v) ?? _rfc822Parser.parseUtc(v);
}