diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 5b0e8ff3b..8108b19c8 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -19,6 +19,8 @@ #include #include +#include +#include #include //---------------------------------------------------------------------------- @@ -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(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; } }