parseDate static method

DateTime parseDate(
  1. String content
)

Implementation

static DateTime parseDate(String content) {
  if (content.length != 4 + 2 + 2) {
    throw FormatException('Invalid date definition: $content');
  }
  final year = int.tryParse(content.substring(0, 4));
  final month = int.tryParse(content.substring(4, 6));
  final day = int.tryParse(content.substring(6));
  if (year == null || month == null || day == null) {
    throw FormatException('Invalid date definition: $content');
  }
  return DateTime(year, month, day);
}