This commit is contained in:
Haibo 2019-01-07 23:51:01 +08:00 committed by Nomango
parent 125c66df3e
commit c165db986b
3 changed files with 12 additions and 12 deletions

View File

@ -35,7 +35,7 @@ namespace easy2d
{
}
TimePoint::TimePoint(const Duration& dur)
TimePoint::TimePoint(long long dur)
: dur(dur)
{
}
@ -52,29 +52,29 @@ namespace easy2d
const TimePoint TimePoint::operator+(const Duration & dur) const
{
return TimePoint(dur + dur);
return TimePoint{ (dur + dur).Milliseconds() };
}
const TimePoint TimePoint::operator-(const Duration & dur) const
{
return TimePoint(dur - dur);
return TimePoint{ (dur - dur).Milliseconds() };
}
TimePoint & TimePoint::operator+=(const Duration & other)
{
dur += other;
dur += other.Milliseconds();
return (*this);
}
TimePoint & TimePoint::operator-=(const Duration &other)
{
dur -= other;
dur -= other.Milliseconds();
return (*this);
}
const Duration TimePoint::operator-(const TimePoint & other) const
{
return dur - other.dur;
return Duration{ dur - other.dur };
}
TimePoint& TimePoint::operator=(const TimePoint & other) E2D_NOEXCEPT
@ -449,7 +449,7 @@ namespace easy2d
const long long whole = (count.QuadPart / freq.QuadPart) * 1000LL;
const long long part = (count.QuadPart % freq.QuadPart) * 1000LL / freq.QuadPart;
return TimePoint{ Duration{ whole + part } };
return TimePoint{ whole + part };
}
Duration easy2d::time::ParseDuration(const std::wstring & str)

View File

@ -44,7 +44,7 @@ namespace easy2d
public:
Duration();
Duration(
explicit Duration(
long long milliseconds
);
@ -147,7 +147,7 @@ namespace easy2d
TimePoint();
explicit TimePoint(
const Duration&
long long
);
TimePoint(
@ -159,7 +159,7 @@ namespace easy2d
);
// 是否是零时
inline bool IsZero() const { return dur.IsZero(); }
inline bool IsZero() const { return dur == 0; }
const TimePoint operator + (const Duration &) const;
const TimePoint operator - (const Duration &) const;
@ -173,7 +173,7 @@ namespace easy2d
TimePoint& operator = (TimePoint &&) E2D_NOEXCEPT;
private:
Duration dur;
long long dur;
};
// 获取当前时间