diff --git a/Core/Version.cpp b/Core/Version.cpp index 775f99e4..87693eed 100644 --- a/Core/Version.cpp +++ b/Core/Version.cpp @@ -26,6 +26,9 @@ Version::Version(int major, int minor, int build) Major = major; Minor = minor; Build = build; + + // 有可能是 170325 这样的写法 + if (build > 120000) SetCompile(build); } Version::Version(const Version& ver) @@ -93,6 +96,21 @@ Version& Version::SetCompile(int year, int month, int day) return *this; } +// 设置编译日期 170325 +Version& Version::SetCompile(int buildday) +{ + int day = buildday % 100; + buildday /= 100; + int month = buildday % 100; + int year = buildday / 100 + 2000; + + DateTime dt(2000, 1, 1); + DateTime dt2(year, month, day); + Build = (dt2 - dt).TotalDays(); + + return *this; +} + String Version::ToString() const { String str; diff --git a/Core/Version.h b/Core/Version.h index 4afd2ba8..c1b35dbb 100644 --- a/Core/Version.h +++ b/Core/Version.h @@ -30,7 +30,10 @@ public: // 根据版本号反推编译时间。 DateTime Compile() const; + // 设置编译日期 Version& SetCompile(int year, int month, int day); + // 设置编译日期 170325 + Version& SetCompile(int buildday); String ToString() const; };