looksLikeDate static method

bool looksLikeDate(
  1. String text
)

Implementation

static bool looksLikeDate(String text) {
  int n = text.length;
  if ( n < 6 || n > 40 ) {
    return false;
  }
  int i = 0;
  while (i < 4) {
    int c = text.codeUnitAt(i);
    if ( c < 48 || c > 57 ) {
      return false;
    }
    i = i + 1;
  }
  int sep = text.codeUnitAt(4);
  if ( sep != 45 ) {
    return false;
  }
  int d = text.codeUnitAt(5);
  if ( d < 48 || d > 57 ) {
    return false;
  }
  return true;
}