版本类的编译日期支持170325这样的写法
This commit is contained in:
parent
0c0fa15cdd
commit
6de4d5568b
|
@ -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;
|
||||
|
|
|
@ -30,7 +30,10 @@ public:
|
|||
|
||||
// 根据版本号反推编译时间。
|
||||
DateTime Compile() const;
|
||||
// 设置编译日期
|
||||
Version& SetCompile(int year, int month, int day);
|
||||
// 设置编译日期 170325
|
||||
Version& SetCompile(int buildday);
|
||||
|
||||
String ToString() const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue