From d76bc78a1247d0ac5d151a510b8d6ba231daa043 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Feb 2009 12:50:48 -0500 Subject: [PATCH] ENH: Factor out nightly start time computation Move generation of the nightly start time string from cmCTestUpdateHandler::ProcessHandler into cmCTestVC. --- Source/CTest/cmCTestUpdateHandler.cxx | 13 +------------ Source/CTest/cmCTestVC.cxx | 18 ++++++++++++++++++ Source/CTest/cmCTestVC.h | 3 +++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index e2cc0f73f..ff868829d 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -364,18 +364,7 @@ int cmCTestUpdateHandler::ProcessHandler() std::string extra_update_opts; if ( this->CTest->GetTestModel() == cmCTest::NIGHTLY ) { - struct tm* t = this->CTest->GetNightlyTime( - this->CTest->GetCTestConfiguration("NightlyStartTime"), - this->CTest->GetTomorrowTag()); - char current_time[1024]; - sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d", - t->tm_year + 1900, - t->tm_mon + 1, - t->tm_mday, - t->tm_hour, - t->tm_min, - t->tm_sec); - std::string today_update_date = current_time; + std::string today_update_date = vc->GetNightlyTime(); // TODO: SVN switch ( this->UpdateType ) diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index d03b23b1f..594667448 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -71,6 +71,24 @@ std::string cmCTestVC::ComputeCommandLine(char const* const* cmd) return line.str(); } +//---------------------------------------------------------------------------- +std::string cmCTestVC::GetNightlyTime() +{ + // Get the nightly start time corresponding to the current dau. + struct tm* t = this->CTest->GetNightlyTime( + this->CTest->GetCTestConfiguration("NightlyStartTime"), + this->CTest->GetTomorrowTag()); + char current_time[1024]; + sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d", + t->tm_year + 1900, + t->tm_mon + 1, + t->tm_mday, + t->tm_hour, + t->tm_min, + t->tm_sec); + return current_time; +} + //---------------------------------------------------------------------------- void cmCTestVC::Cleanup() { diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h index 4564e70af..e1228e027 100644 --- a/Source/CTest/cmCTestVC.h +++ b/Source/CTest/cmCTestVC.h @@ -39,6 +39,9 @@ public: /** Top-level source directory. */ void SetSourceDirectory(std::string const& dir); + /** Get the date/time specification for the current nightly start time. */ + std::string GetNightlyTime(); + /** Perform cleanup operations on the work tree. */ void Cleanup();