bodyAsDateTime method
Implementation
DateTime bodyAsDateTime() {
if (data is String) {
return DateTime.tryParse(data) ??
(throw FormatException("Invalid DateTime: $data"));
}
throw FormatException("Cannot convert ${data.runtimeType} to DateTime.");
}