I have a C ++ project that should print a revision string. The audit string is set by the company, and the protocol includes build time as yyyy / mm / dd.
I use to indicate this as a macro from the build system, but this is no longer an option because the clutter fills the precompiled headers (in incremental builds when the day changes).
I am trying to implement this with getting the build date from the compiler, but __DATE__ and __TIMESTAMP__ specify the month in Mmm.
Any ideas how I can take a month as a number?
based on the answer below the version it ends with:
#define __MONTH__ (\ __DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? "01" : "06") \ : __DATE__ [2] == 'b' ? "02" \ : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? "03" : "04") \ : __DATE__ [2] == 'y' ? "05" \ : __DATE__ [2] == 'l' ? "07" \ : __DATE__ [2] == 'g' ? "08" \ : __DATE__ [2] == 'p' ? "09" \ : __DATE__ [2] == 't' ? "10" \ : __DATE__ [2] == 'v' ? "11" \ : "12") ... std::string udate = __DATE__; std::string date = udate.substr(7, 4) + "/" + __MONTH__ + "/" + udate.substr(4, 2); boost::replace_all(date, " ", "0");
thanks
source share