View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015238CMakeCMakepublic2014-11-09 04:422016-06-10 14:31
ReporterDudi 
Assigned ToKitware Robot 
PrioritylowSeverityfeatureReproducibilityN/A
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0015238: Add timestamp in seconds starts at the Unix Epoch on January 1st, 1970 at UTC.
DescriptionIt 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
TagsNo tags attached.
Attached Filespatch file icon cmake_string_timestamp_e.patch [^] (2,640 bytes) 2014-11-09 10:50 [Show Content]

 Relationships

  Notes
(0037166)
David Cole (manager)
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 (reporter)
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 (manager)
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 (administrator)
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.

 Issue History
Date Modified Username Field Change
2014-11-09 04:42 Dudi New Issue
2014-11-09 08:57 David Cole Note Added: 0037166
2014-11-09 08:59 David Cole Note Edited: 0037166
2014-11-09 10:50 Dudi File Added: cmake_string_timestamp_e.patch
2014-11-09 10:52 Dudi Note Added: 0037167
2014-11-10 11:50 Brad King Note Added: 0037169
2016-06-10 14:29 Kitware Robot Note Added: 0042660
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team