From 81ffa033f8f73a0ef9888567c58b092532186748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A8=D0=B2=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Sat, 17 Jul 2021 23:52:40 +0400 Subject: [PATCH] FIX-18 : fix issue #18 - about cron with multiple hours --- src/CronType.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CronType.php b/src/CronType.php index ff41032..b52f46b 100644 --- a/src/CronType.php +++ b/src/CronType.php @@ -73,6 +73,14 @@ public static function parse(string $expression) : static::once((int) $matches[1]); } + // Parse ranges of selected values like "1-5,21-23" - it's multiple. + if (preg_match("/^([0-9]+)\-([0-9]+),([0-9]+)\-([0-9]+)$/", $expression, $matches)) { + $count = $matches[2] - $matches[1] + 1; + return $count > 1 + ? static::multiple($count) + : static::once((int) $matches[1]); + } + // Parse incremental expressions like "*/2", "1-4/10" or "1,3/4". if (preg_match("/(.+)\/([0-9]+)$/", $expression, $matches)) { $range = static::parse($matches[1]);