版本类的编译日期支持170325这样的写法
This commit is contained in:
parent
0c0fa15cdd
commit
6de4d5568b
|
@ -26,6 +26,9 @@ Version::Version(int major, int minor, int build)
|
||||||
Major = major;
|
Major = major;
|
||||||
Minor = minor;
|
Minor = minor;
|
||||||
Build = build;
|
Build = build;
|
||||||
|
|
||||||
|
// 有可能是 170325 这样的写法
|
||||||
|
if (build > 120000) SetCompile(build);
|
||||||
}
|
}
|
||||||
|
|
||||||
Version::Version(const Version& ver)
|
Version::Version(const Version& ver)
|
||||||
|
@ -93,6 +96,21 @@ Version& Version::SetCompile(int year, int month, int day)
|
||||||
return *this;
|
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 Version::ToString() const
|
||||||
{
|
{
|
||||||
String str;
|
String str;
|
||||||
|
|
|
@ -30,7 +30,10 @@ public:
|
||||||
|
|
||||||
// 根据版本号反推编译时间。
|
// 根据版本号反推编译时间。
|
||||||
DateTime Compile() const;
|
DateTime Compile() const;
|
||||||
|
// 设置编译日期
|
||||||
Version& SetCompile(int year, int month, int day);
|
Version& SetCompile(int year, int month, int day);
|
||||||
|
// 设置编译日期 170325
|
||||||
|
Version& SetCompile(int buildday);
|
||||||
|
|
||||||
String ToString() const;
|
String ToString() const;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue