From 6de4d5568b4b8f861535cfee165deebd32f37015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Sat, 25 Mar 2017 17:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=B1=BB=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=97=A5=E6=9C=9F=E6=94=AF=E6=8C=81170325=E8=BF=99?= =?UTF-8?q?=E6=A0=B7=E7=9A=84=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Version.cpp | 18 ++++++++++++++++++ Core/Version.h | 3 +++ 2 files changed, 21 insertions(+) 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; };