Check start/end/days of week in cron and active/deactivate flights accordingly
This commit is contained in:
@@ -39,6 +39,19 @@ class Days extends Enum
|
||||
'Su' => Days::SUNDAY,
|
||||
];
|
||||
|
||||
/**
|
||||
* Map the ISO8601 numeric today to day
|
||||
*/
|
||||
public static $isoDayMap = [
|
||||
1 => Days::MONDAY,
|
||||
2 => Days::TUESDAY,
|
||||
3 => Days::WEDNESDAY,
|
||||
4 => Days::THURSDAY,
|
||||
5 => Days::FRIDAY,
|
||||
6 => Days::SATURDAY,
|
||||
7 => Days::SUNDAY,
|
||||
];
|
||||
|
||||
/**
|
||||
* Create the masked value for the days of week
|
||||
* @param array $days
|
||||
@@ -64,4 +77,14 @@ class Days extends Enum
|
||||
{
|
||||
return ($mask & $day) === $day;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the mask contain today?
|
||||
* @param $val
|
||||
* @return bool
|
||||
*/
|
||||
public static function isToday($val): bool
|
||||
{
|
||||
return static::in($val, static::$isoDayMap[(int) date('N')]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user