diff options
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 5b0e8ff..8108b19 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -19,6 +19,8 @@ #include <cmsys/ios/sstream> #include <cmsys/Process.h> +#include <sys/types.h> +#include <time.h> #include <ctype.h> //---------------------------------------------------------------------------- @@ -336,16 +338,28 @@ private: Person author; this->ParsePerson(this->Line.c_str()+7, author); this->Rev.Author = author.Name; - char buf[1024]; + + // Convert the time to a human-readable format that is also easy + // to machine-parse: "CCYY-MM-DD hh:mm:ss". + time_t seconds = static_cast<time_t>(author.Time); + struct tm* t = gmtime(&seconds); + char dt[1024]; + sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", + t->tm_year+1900, t->tm_mon+1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + this->Rev.Date = dt; + + // Add the time-zone field "+zone" or "-zone". + char tz[32]; if(author.TimeZone >= 0) { - sprintf(buf, "%lu +%04ld", author.Time, author.TimeZone); + sprintf(tz, " +%04ld", author.TimeZone); } else { - sprintf(buf, "%lu -%04ld", author.Time, -author.TimeZone); + sprintf(tz, " -%04ld", -author.TimeZone); } - this->Rev.Date = buf; + this->Rev.Date += tz; } } |