Check start/end/days of week in cron and active/deactivate flights accordingly

This commit is contained in:
Nabeel Shahzad
2018-04-12 16:12:32 -05:00
parent 395642f69c
commit 9d3d284df7
6 changed files with 224 additions and 6 deletions

View File

@@ -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')]);
}
}