diff --git a/Help/command/string.rst b/Help/command/string.rst index 2c7847acc3793157cc31530d4792309b27cab17e..698a91dcad2c0cd5adf5dea5cfb37d45f0980588 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -296,6 +296,7 @@ specifiers: :: + %% A literal percent sign (%). %d The day of the current month (01-31). %H The hour on a 24-hour clock (00-23). %I The hour on a 12-hour clock (01-12). diff --git a/Help/release/dev/timestamp-percent.rst b/Help/release/dev/timestamp-percent.rst new file mode 100644 index 0000000000000000000000000000000000000000..046d6c507e43f49fab09d29d3e065e0eaaeea271 --- /dev/null +++ b/Help/release/dev/timestamp-percent.rst @@ -0,0 +1,5 @@ +timestamp-percent +----------------- + +* The :command:`string(TIMESTAMP)` command learned to treat ``%%`` + as a way to encode plain ``%``. diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 1e5ac5b2d0969290ea43de03626e9fbc3ed6b398..3d42e262e2bdbe1c7e31c24e2db20fdcd0cfbc8c 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -136,6 +136,7 @@ std::string cmTimestamp::AddTimestampComponent(char flag, case 'w': case 'y': case 'Y': + case '%': break; case 's': // Seconds since UNIX epoch (midnight 1-jan-1970) { diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt index c12b0707e66536b3415f37a724f3cc4a0bf0d040..653974c620a29eac7eea3be674a8fe9269e88fcf 100644 --- a/Tests/RunCMake/string/Timestamp-stderr.txt +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -1 +1 @@ -RESULT=2005-08-07 23:19:49 Sun Aug 05 day=219 wd=0 week=32 %%I=11 +RESULT=2005-08-07 23:19:49 Sun Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789 diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake index 1232300156bc2b6e8b84598ee98f13627a947dc7..d2420394292941223eb161fdc9e26492b1aa8c3a 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 %b %y day=%j wd=%w week=%U %%I=%I" UTC) +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %a %b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC) message("RESULT=${RESULT}")