function get_related_dates($projectname, $basedate) { include "cdash/config.php"; require_once "cdash/pdo.php"; $dates = array(); $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); pdo_select_db("{$CDASH_DB_NAME}", $db); $dbQuery = pdo_query("SELECT nightlytime FROM project WHERE name='{$projectname}'"); if (pdo_num_rows($dbQuery) > 0) { $project = pdo_fetch_array($dbQuery); $nightlytime = $project['nightlytime']; //echo "query result nightlytime: " . $nightlytime . "<br/>"; } else { $nightlytime = "00:00:00"; //echo "default nightlytime: " . $nightlytime . "<br/>"; } if (!isset($basedate) || strlen($basedate) == 0) { $basedate = gmdate(FMT_DATE); } // Convert the nightly time into GMT $nightlytime = gmdate(FMT_TIME, strtotime($nightlytime)); $nightlyhour = time2hour($nightlytime); $nightlyminute = time2minute($nightlytime); $nightlysecond = time2second($nightlytime); $basemonth = date2month($basedate); $baseday = date2day($basedate); $baseyear = date2year($basedate); $dates['nightly+2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 2, $baseyear); $dates['nightly+1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 1, $baseyear); $dates['nightly-0'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday, $baseyear); $dates['nightly-1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 1, $baseyear); $dates['nightly-2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 2, $baseyear); // Snapshot of "now" // $currentgmtime = time(); $currentgmdate = gmdate(FMT_DATE, $currentgmtime); // Find the most recently past nightly time: // $todaymonth = date2month($currentgmdate); $todayday = date2day($currentgmdate); $todayyear = date2year($currentgmdate); $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); while ($currentnightly > $currentgmtime) { $todayday = $todayday - 1; $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); } $dates['now'] = $currentgmtime; $dates['most-recent-nightly'] = $currentnightly; $dates['today_utc'] = $currentgmdate; $dates['basedate'] = gmdate(FMT_DATE, $dates['nightly-0']); // CDash equivalent of DART1's "last rollup time" if ($dates['basedate'] === $dates['today_utc']) { // If it's today, it's now: $dates['last-rollup-time'] = $dates['now']; } else { // If it's not today, it's the nightly time on the basedate: $dates['last-rollup-time'] = $dates['nightly-0']; } return $dates; }
function get_related_dates($projectnightlytime, $basedate) { $dates = array(); $nightlytime = $projectnightlytime; if (!isset($basedate) || strlen($basedate) == 0) { $basedate = gmdate(FMT_DATE); } // Convert the nightly time into GMT $nightlytime = gmdate(FMT_TIME, strtotime($nightlytime)); $nightlyhour = time2hour($nightlytime); $nightlyminute = time2minute($nightlytime); $nightlysecond = time2second($nightlytime); $basemonth = date2month($basedate); $baseday = date2day($basedate); $baseyear = date2year($basedate); $dates['nightly+2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 2, $baseyear); $dates['nightly+1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 1, $baseyear); $dates['nightly-0'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday, $baseyear); $dates['nightly-1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 1, $baseyear); $dates['nightly-2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 2, $baseyear); // Snapshot of "now" // $currentgmtime = time(); $currentgmdate = gmdate(FMT_DATE, $currentgmtime); // Find the most recently past nightly time: // $todaymonth = date2month($currentgmdate); $todayday = date2day($currentgmdate); $todayyear = date2year($currentgmdate); $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); while ($currentnightly > $currentgmtime) { $todayday = $todayday - 1; $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); } $dates['now'] = $currentgmtime; $dates['most-recent-nightly'] = $currentnightly; $dates['today_utc'] = $currentgmdate; $dates['basedate'] = gmdate(FMT_DATE, $dates['nightly-0']); // CDash equivalent of DART1's "last rollup time" if ($dates['basedate'] === $dates['today_utc']) { // If it's today, it's now: $dates['last-rollup-time'] = $dates['now']; } else { // If it's not today, it's the nightly time on the basedate: $dates['last-rollup-time'] = $dates['nightly-0']; } return $dates; }
/** Get dates * today: the *starting* timestamp of the current dashboard * previousdate: the date in Y-m-d format of the previous dashboard * nextdate: the date in Y-m-d format of the next dashboard */ function get_dates($date, $nightlytime) { $nightlytime = strtotime($nightlytime); $nightlyhour = date("H", $nightlytime); $nightlyminute = date("i", $nightlytime); $nightlysecond = date("s", $nightlytime); if (!isset($date) || strlen($date) == 0) { $date = date(FMT_DATE); // the date is always the date of the server if (date(FMT_TIME) > date(FMT_TIME, $nightlytime)) { $date = date(FMT_DATE, time() + 3600 * 24); //next day } } else { // If the $nightlytime is in the morning it's actually the day after if (date(FMT_TIME, $nightlytime) < '12:00:00') { $date = date(FMT_DATE, strtotime($date) + 3600 * 24); // previous date } } $today = mktime($nightlyhour, $nightlyminute, $nightlysecond, date2month($date), date2day($date), date2year($date)) - 3600 * 24; // starting time // If the $nightlytime is in the morning it's actually the day after if (date(FMT_TIME, $nightlytime) < '12:00:00') { $date = date(FMT_DATE, strtotime($date) - 3600 * 24); // previous date } $todaydate = mktime(0, 0, 0, date2month($date), date2day($date), date2year($date)); $previousdate = date(FMT_DATE, $todaydate - 3600 * 24); $nextdate = date(FMT_DATE, $todaydate + 3600 * 24); return array($previousdate, $today, $nextdate, $date); }
?> </b></font></td> </tr> <?php } // end buildfailing ?> <?php if ($testfailing) { ?> <tr> <td bgcolor="#DDDDDD" id="nob"><font size="2">Tests have been failing since <b> <?php if ($testfailingdays > 1) { $date = date2year($datefirsttestfailing) . date2month($datefirsttestfailing) . date2day($datefirsttestfailing); echo "<a href=\"index.php?project=" . urlencode($project_array["name"]) . "&date=" . $date . "\">" . $datefirsttestfailing . "</a> (" . $testfailingdays . " days)"; } else { if ($testfailingdays == 1) { echo $datefirsttestfailing . " (" . $testfailingdays . " day)"; } else { echo $datefirsttestfailing . " (today)"; } } ?> </b></font></td> </tr> <?php } // end buildfailing ?>
return; } $project = pdo_query("SELECT name FROM project WHERE id='{$projectid}'"); $project_array = pdo_fetch_array($project); $currentUTCtime = gmdate(FMT_DATETIME, $currenttime); // Find the last build corresponding to thie siteid and buildid $lastbuild = pdo_query("SELECT starttime FROM build\n WHERE siteid='{$siteid}' AND type='{$buildtype}' AND name='{$buildname}'\n AND projectid='{$projectid}' AND starttime<='{$currentUTCtime}' ORDER BY starttime DESC LIMIT 1"); if (pdo_num_rows($lastbuild) > 0) { $lastbuild_array = pdo_fetch_array($lastbuild); $datelastbuild = $lastbuild_array['starttime']; $lastsbuilddays = round(($currenttime - strtotime($datelastbuild)) / (3600 * 24)); } else { $lastsbuilddays = -1; } ?> <table width="100%" border="0"> <tr> <td bgcolor="#DDDDDD" id="nob"><font size="2"> <?php if ($lastsbuilddays == -1) { echo 'This build has never submitted.'; } elseif ($lastsbuilddays >= 0) { $date = date2year($datelastbuild) . date2month($datelastbuild) . date2day($datelastbuild); echo 'This build has not been submitting since <b><a href="index.php?project=' . urlencode($project_array['name']) . '&date=' . $date . '">' . date('M j, Y ', strtotime($datelastbuild)) . '</a> (' . $lastsbuilddays . ' days)</b>'; } ?> </font></td> </tr> </table> </html>