Work

忙闲时

对忙时的定义,可能是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     }

posted on 2012-10-25 23:32 lonelycastle 阅读(55) 评论(0)  编辑 收藏 引用 所属分类: work


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理