function getScheduledTasks($notification) { // Reports have to be sent when the period ends for all websites $maxHourOffset = 0; $uniqueTimezones = Piwik_SitesManager_API::getInstance()->getUniqueSiteTimezones(); $baseDate = Piwik_Date::factory("1971-01-01"); foreach ($uniqueTimezones as &$timezone) { $offsetDate = Piwik_Date::factory($baseDate->toString(), $timezone); // Earlier means a negative timezone if ($offsetDate->isEarlier($baseDate)) { // Gets the timezone offset $hourOffset = 24 - date('H', $offsetDate->getTimestamp()); if ($hourOffset > $maxHourOffset) { $maxHourOffset = $hourOffset; } } } $tasks =& $notification->getNotificationObject(); $dailySchedule = new Piwik_ScheduledTime_Daily(); $dailySchedule->setHour($maxHourOffset); $tasks[] = new Piwik_ScheduledTask($this, 'dailySchedule', $dailySchedule); $weeklySchedule = new Piwik_ScheduledTime_Weekly(); $weeklySchedule->setHour($maxHourOffset); $tasks[] = new Piwik_ScheduledTask($this, 'weeklySchedule', $weeklySchedule); $monthlySchedule = new Piwik_ScheduledTime_Monthly(); $monthlySchedule->setHour($maxHourOffset); $tasks[] = new Piwik_ScheduledTask($this, 'monthlySchedule', $monthlySchedule); }
public function test_setDay_ScheduledTime_Monthly_Over_31() { try { $monthlySchedule = new Piwik_ScheduledTime_Monthly(); $monthlySchedule->setDay(32); $this->fail("Exception not raised."); } catch (Exception $expected) { $this->pass(); return; } }
/** * Tests invalid call to setDay on Piwik_ScheduledTime_Monthly * @group Core * @group ScheduledTime */ public function testSetDayScheduledTimeMonthlyOver31() { try { $monthlySchedule = new Piwik_ScheduledTime_Monthly(); $monthlySchedule->setDay(32); } catch (Exception $e) { return; } $this->fail('Expected exception not raised'); }