summaryrefslogtreecommitdiffstats
path: root/Source/cmXMLWriter.h
diff options
context:
space:
mode:
authorWouter Klouwen <wouter.klouwen@youview.com>2017-11-15 18:00:09 (GMT)
committerWouter Klouwen <wouter.klouwen@youview.com>2017-11-17 15:22:55 (GMT)
commit5fd979a8a3bc13aaf20c2833fe513df192d82fb1 (patch)
tree4a99189a6f387c43f92707645dcb0cfacb3d17ad /Source/cmXMLWriter.h
parente31288582977c10972af9baa3b0e41d758094d21 (diff)
downloadCMake-5fd979a8a3bc13aaf20c2833fe513df192d82fb1.zip
CMake-5fd979a8a3bc13aaf20c2833fe513df192d82fb1.tar.gz
CMake-5fd979a8a3bc13aaf20c2833fe513df192d82fb1.tar.bz2
CTest: adopt std::chrono::system_clock
After the refactor to make CTest use std::chrono::steady_clock for the keeping of time for test duration, there are still references to cmSystemTools::GetTime() left. To further adopt std::chrono for time related activities, this commit changes those remaining references to std::chrono::system_clock::now() calls and alters the storage from either unsigned int or double to std::chrono::system_clock::time_point. For ease of conversion, a converter method is added to cmXMLWriter that converts from a std::chrono::system_clock::time_point to the number of seconds since the UN*X epoch as that is expected behaviour. This means no more casts as required. Functionally should be no difference as the system_clock is implemented in the same terms.
Diffstat (limited to 'Source/cmXMLWriter.h')
-rw-r--r--Source/cmXMLWriter.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index 981255d..c890acf 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -7,6 +7,8 @@
#include "cmXMLSafe.h"
+#include <chrono>
+#include <ctime>
#include <ostream>
#include <stack>
#include <string>
@@ -99,6 +101,22 @@ private:
return cmXMLSafe(value).Quotes(false);
}
+ /*
+ * Convert a std::chrono::system::time_point to the number of seconds since
+ * the UN*X epoch.
+ *
+ * It would be tempting to convert a time_point to number of seconds by
+ * using time_since_epoch(). Unfortunately the C++11 standard does not
+ * specify what the epoch of the system_clock must be.
+ * Therefore we must assume it is an arbitary point in time. Instead of this
+ * method, it is recommended to convert it by means of the to_time_t method.
+ */
+ static std::time_t SafeContent(
+ std::chrono::system_clock::time_point const& value)
+ {
+ return std::chrono::system_clock::to_time_t(value);
+ }
+
template <typename T>
static T SafeContent(T value)
{