summaryrefslogtreecommitdiff
path: root/Source/cmTimestamp.h
diff options
context:
space:
mode:
authorPeter Würth <wuerth.peter@freenet.de>2022-01-27 15:20:15 +0100
committerBrad King <brad.king@kitware.com>2022-01-28 06:23:57 -0500
commitc050d6a01e14500903619589e69a973f1215d109 (patch)
treed78eb4dec319610788d4518d2fe3225e889b9b7c /Source/cmTimestamp.h
parent44939f01e761568ab9fe511d2ddf81a48c7c54b9 (diff)
downloadcmake-c050d6a01e14500903619589e69a973f1215d109.tar.gz
string(TIMESTAMP): add %f specifier for microseconds
The %f specified extends the string(TIMESTAMP) and file(TIMESTAMP) commands to output the timestamp with a microsecond resolution. This convention is offered by python's datetime module. Before, the precision was limited to seconds. The implementation is done by extending existing cmTimestamp methods with a `microseconds` parameter. This parameter is optional in order to be backwards compatible. The timestamps are now received in a cross-platform manner using libuv, since the standard C functions like time() don't allow for sub-second precision. This requires libuv 1.28 or higher. We already require higher than that on Windows, so update the required version for other platforms. Implements: #19335
Diffstat (limited to 'Source/cmTimestamp.h')
-rw-r--r--Source/cmTimestamp.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h
index 0e2c20006e..ada5006d45 100644
--- a/Source/cmTimestamp.h
+++ b/Source/cmTimestamp.h
@@ -4,6 +4,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstdint>
#include <ctime>
#include <string>
@@ -23,9 +24,14 @@ public:
std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
bool utcFlag) const;
+ std::string CreateTimestampFromTimeT(time_t timeT, uint32_t microseconds,
+ std::string formatString,
+ bool utcFlag) const;
+
private:
time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
std::string AddTimestampComponent(char flag, struct tm& timeStruct,
- time_t timeT) const;
+ time_t timeT,
+ uint32_t microseconds = 0) const;
};