static function getWeekStartingDay($week = 0) { ExtraWatchLog::debug("getting week starting day: " . $week); if (!$week) { $weekDiff = 0; } else { $currentWeek = ExtraWatchDate::getCurrentWeek(); // OK $weekDiff = $currentWeek - $week; // difference between selected week number since 1.1.1970 and current week number ExtraWatchLog::debug("current week: {$currentWeek} weekDiff: {$weekDiff}"); } $dayOfWeek = ExtraWatchDate::dayOfWeek(); $dateToday = ExtraWatchDate::jwDateToday(); return $dateToday - $dayOfWeek - $weekDiff * 7 + 1; // +1 to make it start on monday }