198 lines
6.5 KiB
Plaintext
198 lines
6.5 KiB
Plaintext
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
// NoesisGUI - http://www.noesisengine.com
|
||
|
|
// Copyright (c) 2013 Noesis Technologies S.L. All Rights Reserved.
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
|
||
|
|
|
||
|
|
namespace Noesis
|
||
|
|
{
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan::TimeSpan(): mTicks(0)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan::TimeSpan(double seconds): mTicks(static_cast<int64_t>(seconds * 10000000.0))
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan::TimeSpan(int64_t ticks): mTicks(ticks)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan TimeSpan::Zero()
|
||
|
|
{
|
||
|
|
return TimeSpan((int64_t)0);
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline int TimeSpan::GetDays() const
|
||
|
|
{
|
||
|
|
return static_cast<int>(mTicks / 864000000000LL);
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline int TimeSpan::GetHours() const
|
||
|
|
{
|
||
|
|
return static_cast<int>((mTicks / 36000000000LL) % 24L);
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline int TimeSpan::GetMinutes() const
|
||
|
|
{
|
||
|
|
return static_cast<int>((mTicks / 600000000L) % 60L);
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline int TimeSpan::GetSeconds() const
|
||
|
|
{
|
||
|
|
return static_cast<int>((mTicks / 10000000L) % 60L);
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline int TimeSpan::GetMilliseconds() const
|
||
|
|
{
|
||
|
|
return static_cast<int>((mTicks / 10000L) % 1000L);
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline int64_t TimeSpan::GetTicks() const
|
||
|
|
{
|
||
|
|
return mTicks;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline double TimeSpan::GetTotalDays() const
|
||
|
|
{
|
||
|
|
return mTicks / 864000000000.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline double TimeSpan::GetTotalHours() const
|
||
|
|
{
|
||
|
|
return mTicks / 36000000000.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline double TimeSpan::GetTotalMinutes() const
|
||
|
|
{
|
||
|
|
return mTicks / 600000000.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline double TimeSpan::GetTotalSeconds() const
|
||
|
|
{
|
||
|
|
return mTicks / 10000000.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline double TimeSpan::GetTotalMilliseconds() const
|
||
|
|
{
|
||
|
|
return mTicks / 10000.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline double TimeSpan::GetTimeInSeconds() const
|
||
|
|
{
|
||
|
|
return mTicks / 10000000.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline bool TimeSpan::operator==(const TimeSpan& other) const
|
||
|
|
{
|
||
|
|
return mTicks == other.mTicks;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline bool TimeSpan::operator!=(const TimeSpan& other) const
|
||
|
|
{
|
||
|
|
return mTicks != other.mTicks;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan& TimeSpan::operator+=(const TimeSpan& other)
|
||
|
|
{
|
||
|
|
mTicks += other.mTicks;
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan& TimeSpan::operator-=(const TimeSpan& other)
|
||
|
|
{
|
||
|
|
mTicks -= other.mTicks;
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan& TimeSpan::operator*=(float value)
|
||
|
|
{
|
||
|
|
mTicks = static_cast<int64_t>(mTicks * value);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan operator+(const TimeSpan& t0, const TimeSpan& t1)
|
||
|
|
{
|
||
|
|
return TimeSpan(t0.GetTicks() + t1.GetTicks());
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan operator-(const TimeSpan& t0, const TimeSpan& t1)
|
||
|
|
{
|
||
|
|
return TimeSpan(t0.GetTicks() - t1.GetTicks());
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan operator*(const TimeSpan& t, float value)
|
||
|
|
{
|
||
|
|
return TimeSpan(static_cast<int64_t>(t.GetTicks() * value));
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan operator*(float value, const TimeSpan& t)
|
||
|
|
{
|
||
|
|
return TimeSpan(static_cast<int64_t>(value * t.GetTicks()));
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline float operator/(const TimeSpan& t0, const TimeSpan& t1)
|
||
|
|
{
|
||
|
|
return static_cast<float>(
|
||
|
|
static_cast<double>(t0.GetTicks()) / static_cast<double>(t1.GetTicks()));
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline TimeSpan operator/(const TimeSpan& t, float value)
|
||
|
|
{
|
||
|
|
return TimeSpan(static_cast<int64_t>(t.GetTicks() / value));
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline bool operator<(const TimeSpan& t0, const TimeSpan& t1)
|
||
|
|
{
|
||
|
|
return t0.GetTicks() < t1.GetTicks();
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline bool operator<=(const TimeSpan& t0, const TimeSpan& t1)
|
||
|
|
{
|
||
|
|
return t0.GetTicks() <= t1.GetTicks();
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline bool operator>(const TimeSpan& t0, const TimeSpan& t1)
|
||
|
|
{
|
||
|
|
return t0.GetTicks() > t1.GetTicks();
|
||
|
|
}
|
||
|
|
|
||
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
inline bool operator>=(const TimeSpan& t0, const TimeSpan& t1)
|
||
|
|
{
|
||
|
|
return t0.GetTicks() >= t1.GetTicks();
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|