39 template<
typename Rep = Int64,
typename Period = std::ratio<1>>
66 template<
typename Rep = Int64,
typename Period = std::ratio<1>>
67 std::chrono::duration<Rep, Period>
AsChrono()
const;
93 template<
typename Rep = Int64,
typename Period = std::ratio<1>>
104 template<
typename Rep = Int64,
typename Period = std::ratio<1>>
105 static Time Create(
const std::chrono::duration<Rep, Period>& duration);
387 std::chrono::duration<TimeRep, TimePeriod> microseconds;
391 template<
typename Rep,
typename Period>
394 return std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(microseconds).count();
397 template<
typename Rep,
typename Period>
400 return std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(microseconds);
403 template<
typename Rep,
typename Period>
407 newTime.microseconds = std::chrono::duration_cast<std::chrono::duration<TimeRep, TimePeriod>>(std::chrono::duration<Rep, Period>(duration));
411 template<
typename Rep,
typename Period>
415 newTime.microseconds = std::chrono::duration_cast<std::chrono::duration<TimeRep, TimePeriod>>(duration);
421 return Create(std::chrono::steady_clock::now().time_since_epoch());
std::nano TimePeriod
Definition: Time.hpp:19
SDLU_BEGIN typedef Int64 TimeRep
Definition: Time.hpp:18
Basic utility macros, typedefs...
int32_t Int32
Definition: Util.hpp:24
int64_t Int64
Definition: Util.hpp:27
#define SDLU_BEGIN
Definition: Util.hpp:32
This class wraps std::chrono::duration and defines some conversions for commonly used times.
Definition: Time.hpp:24
static Time Create(const Rep &duration)
Stores the given scalar as a time, using the given format.
Definition: Time.hpp:404
friend Time operator-(const Time &left, const Time &right)
Overload of - operator to subtract two Times.
friend bool operator!=(const Time &left, const Time &right)
Overload of != operator comparing two Times.
friend Time & operator/=(Time &left, Int64 right)
Overload of /= operator to divide a Time by a scalar.
float AsSeconds() const
Returns the stored time in seconds.
friend Time operator*(const Time &left, Int64 right)
Overload of * operator to multiply a Time with a scalar.
friend Time operator+(const Time &left, const Time &right)
Overload of + operator to add two Times.
Rep AsValue() const
Returns the stored time in the specified format as a scalar.
Definition: Time.hpp:392
std::chrono::milliseconds AsChronoMilliseconds() const
Returns the stored time in std::chrono::milliseconds.
Time()
Default constructor. Constructs a time with value 0.
friend Time & operator/=(Time &left, float right)
Overload of /= operator to divide a Time by a scalar.
Int32 AsMilliseconds() const
Returns the stored time in milliseconds.
Int64 AsMicroseconds() const
Returns the stored time in microseconds.
friend Time operator%(const Time &left, const Time &right)
Overload of % operator to calculate the modulo of a Time.
friend Time Milliseconds(Int32 milliseconds)
Creates a Time object from a given number of milliseconds.
friend bool operator==(const Time &left, const Time &right)
Overload of == operator comparing two Times.
std::chrono::seconds AsChronoSeconds() const
Returns the stored time in std::chrono::seconds.
friend Time & operator*=(Time &left, Int64 right)
Overload of *= operator to multiply a Time with a scalar.
static Time Now()
Creates a Time object storing the current point in time.
Definition: Time.hpp:419
std::chrono::microseconds AsChronoMicroseconds() const
Returns the stored time in std::chrono::microseconds.
friend Time operator*(float left, const Time &right)
Overload of * operator to multiply a Time with a scalar.
friend Time operator*(Int64 left, const Time &right)
Overload of * operator to multiply a Time with a scalar.
friend Time operator*(const Time &left, float right)
Overload of * operator to multiply a Time with a scalar.
friend Time Seconds(float seconds)
Creates a Time object from a given number of seconds.
std::chrono::duration< Rep, Period > AsChrono() const
Returns the stored time in the specified format as a std::duration.
Definition: Time.hpp:398
friend Time Microseconds(Int64 microseconds)
Creates a Time object from a given number of microseconds.
friend Time operator/(const Time &left, float right)
Overload of / operator to divide a Time by a scalar.
friend float operator/(const Time &left, const Time &right)
Overload of / operator to divide two Times.
friend Time & operator+=(Time &left, const Time &right)
Overload of += operator to add two Times.
friend bool operator<(const Time &left, const Time &right)
Overload of < operator comparing two Times.
friend Time & operator-=(Time &left, const Time &right)
Overload of -= operator to subtract two Times.
friend Time operator-(const Time &right)
Overload of the unary - operator.
friend Time & operator*=(Time &left, float right)
Overload of *= operator to multiply a Time with a scalar.
friend Time operator/(const Time &left, Int64 right)
Overload of / operator to divide a Time by a scalar.
friend Time & operator%=(Time &left, const Time &right)
Overload of % operator to calculate the modulo of a Time.
friend bool operator>=(const Time &left, const Time &right)
Overload of < operator comparing two Times.
friend bool operator<=(const Time &left, const Time &right)
Overload of <= operator comparing two Times.
friend bool operator>(const Time &left, const Time &right)
Overload of > operator comparing two Times.