matches static method

bool matches(
  1. String cron,
  2. DateTime now
)

Implementation

static bool matches(String cron, DateTime now) {
  final normalized = normalize(cron);
  final validation = validate(normalized);
  if (!validation.isValid) return false;

  final parts = normalized.split(RegExp(r'\s+'));
  final weekday = now.weekday % 7;

  return _matchPart(parts[0], now.minute, 0, 59) &&
      _matchPart(parts[1], now.hour, 0, 23) &&
      _matchPart(parts[2], now.day, 1, 31) &&
      _matchPart(parts[3], now.month, 1, 12, aliases: _months) &&
      _matchPart(parts[4], weekday, 0, 7, aliases: _weekdays);
}