Esempio n. 1
0
     }
 } else {
     if (isMatch($input[0], '/work')) {
         $workStartTime = new DateTime('09:30:00');
         $workEndTime = new DateTime('18:30:00');
         $currentTime = new DateTime();
         $nextWorkTime = $currentTime;
         if (!isHoliday($currentTime) && $currentTime->diff($workStartTime)->format('%R') == '-' && $currentTime->diff($workEndTime)->format('%R') == '+') {
             sendMessage($id, "{$senderFirstName}, 請專心工作!");
         } else {
             if ($currentTime->diff($workStartTime)->format('%R') == '+') {
                 $nextWorkTime = $workStartTime;
             } else {
                 $nextWorkTime = $workStartTime->add(new DateInterval('P1D'));
             }
             while (isHoliday($nextWorkTime)) {
                 $nextWorkTime = $nextWorkTime->add(new DateInterval('P1D'));
             }
             $timeDiff = $currentTime->diff($nextWorkTime);
             $h = $timeDiff->d * 24 + $timeDiff->h;
             sendMessage($id, "距離下次返工仲有" . $h . "小時" . $timeDiff->i . "分鐘" . $timeDiff->s . "秒!");
         }
     } else {
         if (isMatch($input[0], '/holiday')) {
             $currentTime = new DateTime();
             $weekDay = $currentTime->format('D');
             $weekDayArr = array("Fri", "Thu", "Wed", "Tue", "Mon");
             $holidayRemain = 0;
             for ($i = 0; $i < 5; $i++) {
                 if ($weekDay == $weekDayArr[$i]) {
                     $holidayRemain = $i + 1;
Esempio n. 2
0
 function isWorkingDay()
 {
     global $AppUI, $baseDir;
     # holiday module
     require_once $baseDir . "/modules/holiday/holiday_func.php";
     if (isHoliday($this)) {
         return 0;
     }
     $working_days = dPgetConfig("cal_working_days");
     $working_days = is_null($working_days) ? array('1', '2', '3', '4', '5') : explode(",", $working_days);
     return in_array($this->getDayOfWeek(), $working_days);
 }