public function testFirstWorkingDayOfMonth() { // Sunday the 1st. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(1, 0)); // Monday the 1st. $this->assertTrue(Filter_Datetime::isFirstWorkingDayOfMonth(1, 1)); // Tuesday the 1st. $this->assertTrue(Filter_Datetime::isFirstWorkingDayOfMonth(1, 2)); // Wednesday the 1st. $this->assertTrue(Filter_Datetime::isFirstWorkingDayOfMonth(1, 3)); // Thirsday the 1st. $this->assertTrue(Filter_Datetime::isFirstWorkingDayOfMonth(1, 4)); // Friday the 1st. $this->assertTrue(Filter_Datetime::isFirstWorkingDayOfMonth(1, 5)); // Saturday the 1st. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(1, 6)); // Sunday the 2nd. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(2, 0)); // Monday the 2nd. $this->assertTrue(Filter_Datetime::isFirstWorkingDayOfMonth(2, 1)); // Tuesday the 2nd. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(2, 2)); // Sunday the 3nd. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(3, 0)); // Monday the 3nd. $this->assertTrue(Filter_Datetime::isFirstWorkingDayOfMonth(3, 1)); // Tuesday the 3nd. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(3, 2)); // Sunday the 4nd. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(4, 0)); // Monday the 4nd. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(4, 1)); // Tuesday the 4nd. $this->assertFalse(Filter_Datetime::isFirstWorkingDayOfMonth(4, 2)); }
$year = date("Y"); $month = date("n"); $monthday = date("j"); // 1 to 31. $weekday = date("w"); // 0 (for Sunday) through 6 (for Saturday). $hour = date("G"); // 0 through 23 $sprintstart = false; $sprintfinish = false; // Every Friday at 2 PM (14:00h) it sends email about the sprint progress. if ($weekday == 5 && $hour == 14) { $email = true; } // On the first business day of the month, at 10 AM, send email about the start of the sprint. if (Filter_Datetime::isFirstWorkingDayOfMonth($monthday, $weekday) && $hour == 10) { $email = true; $sprintstart = true; } // On the last business day of the month, at 2 PM (14:00h), send email about the end of the sprint. if ($monthday == Filter_Datetime::getLastBusinessDayOfMonth($year, $month) && $hour == 14) { $email = true; $sprintfinish = true; } // Determine what to do, or to quit. if (!$email && !$sprintstart && !$sprintfinish) { if ($hour != 1) { die; } } $database_logs = Database_Logs::getInstance();