Merge topic 'ctest-getdate'

458664a727 cmCTest: Avoid dependence on curl for non-network operation
d7990d20b5 cmCTest: Clarify nightly start time construction logic

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10789
This commit is contained in:
Brad King
2025-05-19 12:45:21 +00:00
committed by Kitware Robot

View File

@@ -25,7 +25,6 @@
#include <cmext/algorithm>
#include <cmext/string_view>
#include <cm3p/curl/curl.h>
#include <cm3p/json/value.h>
#include <cm3p/uv.h>
#include <cm3p/zlib.h>
@@ -41,6 +40,8 @@
# include <unistd.h> // IWYU pragma: keep
#endif
#include "cm_get_date.h"
#include "cmCMakePresetsGraph.h"
#include "cmCTestBuildAndTest.h"
#include "cmCTestScriptHandler.h"
@@ -203,23 +204,21 @@ struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
struct tm* lctime;
time_t tctime = time(nullptr);
lctime = gmtime(&tctime);
char buf[1024];
// add todays year day and month to the time in str because
// curl_getdate no longer assumes the day is today
std::snprintf(buf, sizeof(buf), "%d%02d%02d %s", lctime->tm_year + 1900,
lctime->tm_mon + 1, lctime->tm_mday, str.c_str());
cmCTestLog(this, OUTPUT,
"Determine Nightly Start Time" << std::endl
<< " Specified time: " << str
<< std::endl);
// Convert the nightly start time to seconds. Since we are
// providing only a time and a timezone, the current date of
// Convert the nightly start time to seconds. The current date of
// the local machine is assumed. Consequently, nightlySeconds
// is the time at which the nightly dashboard was opened or
// will be opened on the date of the current client machine.
// As such, this time may be in the past or in the future.
time_t ntime = curl_getdate(buf, &tctime);
cmCTestLog(this, DEBUG, " Get curl time: " << ntime << std::endl);
char buf[1024];
std::snprintf(buf, sizeof(buf), "%d%02d%02d %s", lctime->tm_year + 1900,
lctime->tm_mon + 1, lctime->tm_mday, str.c_str());
time_t ntime = cm_get_date(tctime, buf);
cmCTestLog(this, DEBUG,
" Get the nightly start time: " << ntime << std::endl);
tctime = time(nullptr);
cmCTestLog(this, DEBUG, " Get the current time: " << tctime << std::endl);
@@ -2792,7 +2791,7 @@ void cmCTest::SetStopTime(std::string const& time_str)
lctime->tm_mon + 1, lctime->tm_mday, time_str.c_str(),
tzone_offset);
time_t stop_time = curl_getdate(buf, &current_time);
time_t stop_time = cm_get_date(current_time, buf);
if (stop_time == -1) {
this->Impl->StopTime = std::chrono::system_clock::time_point();
return;