MCPcopy Create free account
hub / github.com/Kitware/CMake / SetStopTime

Method SetStopTime

Source/cmCTest.cxx:2726–2762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2724}
2725
2726void cmCTest::SetStopTime(std::string const& time_str)
2727{
2728
2729 struct tm* lctime;
2730 time_t current_time = time(nullptr);
2731 lctime = gmtime(&current_time);
2732 int gm_hour = lctime->tm_hour;
2733 time_t gm_time = mktime(lctime);
2734 lctime = localtime(&current_time);
2735 int local_hour = lctime->tm_hour;
2736
2737 int tzone_offset = local_hour - gm_hour;
2738 if (gm_time > current_time && gm_hour < local_hour) {
2739 // this means gm_time is on the next day
2740 tzone_offset -= 24;
2741 } else if (gm_time < current_time && gm_hour > local_hour) {
2742 // this means gm_time is on the previous day
2743 tzone_offset += 24;
2744 }
2745
2746 tzone_offset *= 100;
2747 char buf[1024];
2748 snprintf(buf, sizeof(buf), "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
2749 lctime->tm_mon + 1, lctime->tm_mday, time_str.c_str(),
2750 tzone_offset);
2751
2752 time_t stop_time = cm_parse_date(current_time, buf);
2753 if (stop_time == -1) {
2754 this->Impl->StopTime = std::chrono::system_clock::time_point();
2755 return;
2756 }
2757 this->Impl->StopTime = std::chrono::system_clock::from_time_t(stop_time);
2758
2759 if (stop_time < current_time) {
2760 this->Impl->StopTime += std::chrono::hours(24);
2761 }
2762}
2763
2764cm::optional<unsigned int> cmCTest::GetRandomSeed() const
2765{

Callers 2

RunMethod · 0.95
InitializeHandlerMethod · 0.80

Calls 2

c_strMethod · 0.80
snprintfFunction · 0.50

Tested by

no test coverage detected