Schedule.parse constructor

Schedule.parse(
  1. String cronFormat
)

Parses the cron-formatted text and creates a schedule out of it.

Implementation

factory Schedule.parse(String cronFormat) {
  final p = cronFormat
      .split(_whitespacesRegExp)
      .where((p) => p.isNotEmpty)
      .toList();
  assert(p.length == 5 || p.length == 6);
  final parts = [
    if (p.length == 5) null,
    ...p,
  ];
  return Schedule(
    seconds: parts[0],
    minutes: parts[1],
    hours: parts[2],
    days: parts[3],
    months: parts[4],
    weekdays: parts[5],
  );
}