Use human-readable Git commit times in Update.xml
Previously we produced commit times formatted like 1261403774 -0500 which is what the Git plumbing prints. Now we use a human-readable format like 2009-12-21 15:28:06 -0500 which is still easy to machine-parse.
This commit is contained in:
parent
5cf77136cb
commit
cb27cfb1cc
|
@ -19,6 +19,8 @@
|
||||||
#include <cmsys/ios/sstream>
|
#include <cmsys/ios/sstream>
|
||||||
#include <cmsys/Process.h>
|
#include <cmsys/Process.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -336,16 +338,28 @@ private:
|
||||||
Person author;
|
Person author;
|
||||||
this->ParsePerson(this->Line.c_str()+7, author);
|
this->ParsePerson(this->Line.c_str()+7, author);
|
||||||
this->Rev.Author = author.Name;
|
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)
|
if(author.TimeZone >= 0)
|
||||||
{
|
{
|
||||||
sprintf(buf, "%lu +%04ld", author.Time, author.TimeZone);
|
sprintf(tz, " +%04ld", author.TimeZone);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(buf, "%lu -%04ld", author.Time, -author.TimeZone);
|
sprintf(tz, " -%04ld", -author.TimeZone);
|
||||||
}
|
}
|
||||||
this->Rev.Date = buf;
|
this->Rev.Date += tz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue