MantisBT - CMake
View Issue Details
0015238CMakeCMakepublic2014-11-09 04:422016-06-10 14:31
Dudi 
Kitware Robot 
lowfeatureN/A
closedmoved 
 
 
0015238: Add timestamp in seconds starts at the Unix Epoch on January 1st, 1970 at UTC.
It would be great to add this small feature, it is often used (by me) for easy remember the compilation time (while making a build).

I propose:
string(TIMESTAMP "%e" [<format string>] [UTC])

It will return:
1415525945
No tags attached.
patch cmake_string_timestamp_e.patch (2,640) 2014-11-09 10:50
https://public.kitware.com/Bug/file/5291/cmake_string_timestamp_e.patch
Issue History
2014-11-09 04:42DudiNew Issue
2014-11-09 08:57David ColeNote Added: 0037166
2014-11-09 08:59David ColeNote Edited: 0037166bug_revision_view_page.php?bugnote_id=37166#r1614
2014-11-09 10:50DudiFile Added: cmake_string_timestamp_e.patch
2014-11-09 10:52DudiNote Added: 0037167
2014-11-10 11:50Brad KingNote Added: 0037169
2016-06-10 14:29Kitware RobotNote Added: 0042660
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0037166)
David Cole   
2014-11-09 08:57   
(edited on: 2014-11-09 08:59)
I see a few problems to overcome before somebody could implement some code to address this feature request:

First the implementation of the TIMESTAMP formatting in cmTimestamp.cxx uses strftime directly, and only allows using the formatting characters that are available on all the platforms CMake must support.

The strftime documentation I found suggests "%s" maps to the formatting you'd like on some systems, but not on Windows with the MS compiler.

So: I'd recommend if somebody implements this, that %s is used.

(Or: if some other choice is made, just consider future expansion, and don't use a character that means something else in strftime for this...)

I'd also say that Unix filetime is always supposed to be expressed in UTC, and comparisons using the numbers from this only make sense if everything is in UTC...

(0037167)
Dudi   
2014-11-09 10:52   
I tried to resolve this problem myself.
Please look at my proposition (cmake_string_timestamp_e.patch).

I not tested it but I think, that will work correctly.
(0037169)
Brad King   
2014-11-10 11:50   
Re 0015238:0037167: Thanks. I agree with 0015238:0037166 that the format placeholder should be "%s" because strftime has that already, but you are correct that we need our own implementation of it because not all strftime implementatiosn provide it.

In AddTimestampComponent I think you can just start with a "if(flag == 's')" block that hard-codes its implementation and returns instead of trying to modify the strftime code path.

Please also update the documentation and tests to cover this.
(0042660)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.