对忙时的定义,可能是6点到23点,也可能是23点到6点
1 $busy_time = array(23, 6);
2
3 private static function checkIsBusy()
4 {
5 // 如果配置无效,默认是free
6 global $busy_time;
7 $nowTime = date('G');
8 if (empty($busy_time) || (count($busy_time)!=2) || ! (is_int($busy_time[0])&&is_int($busy_time[1])) ) {
9 Yii::log('conf error, $free_time format error', 'error', 'shifen');
10 return false;
11 }
12 list($busyStart, $busyEnd) = $busy_time;
13 if ($busyStart <= $busyEnd) {
14 return (($nowTime>=$busyStart) && ($nowTime<=$busyEnd)) ? true:false;
15 }
16 else {
17 return (($nowTime>=$busyStart) || ($nowTime<=$busyEnd)) ? true:false;
18 }
19 }