summaryrefslogtreecommitdiff
path: root/Tests
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 /Tests
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 'Tests')
-rw-r--r--Tests/RunCMake/string/Timestamp-stderr.txt2
-rw-r--r--Tests/RunCMake/string/Timestamp.cmake2
2 files changed, 2 insertions, 2 deletions
diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt
index d54777bd71..f162f52992 100644
--- a/Tests/RunCMake/string/Timestamp-stderr.txt
+++ b/Tests/RunCMake/string/Timestamp-stderr.txt
@@ -1 +1 @@
-RESULT=2005-08-07 23:19:49 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 w_iso=31 %I=11 epoch=1123456789
+RESULT=2005-08-07 23:19:49.000000 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 w_iso=31 %I=11 epoch=1123456789
diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake
index 7fd6d72b0d..531a237bdc 100644
--- a/Tests/RunCMake/string/Timestamp.cmake
+++ b/Tests/RunCMake/string/Timestamp.cmake
@@ -1,3 +1,3 @@
set(ENV{SOURCE_DATE_EPOCH} "1123456789")
-string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %A=%a %B=%b %y day=%j wd=%w week=%U w_iso=%V %%I=%I epoch=%s" UTC)
+string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S.%f %A=%a %B=%b %y day=%j wd=%w week=%U w_iso=%V %%I=%I epoch=%s" UTC)
message("RESULT=${RESULT}")