Hyprland/src/helpers/Timer.cpp
Vaxry 1d70962892 core: move to steady_clock where applicable
avoid issues when system clock gets desynchronized or changed
2024-06-25 16:05:47 +02:00

21 lines
No EOL
571 B
C++

#include "Timer.hpp"
void CTimer::reset() {
m_tpLastReset = std::chrono::steady_clock::now();
}
std::chrono::steady_clock::duration CTimer::getDuration() {
return std::chrono::steady_clock::now() - m_tpLastReset;
}
int CTimer::getMillis() {
return std::chrono::duration_cast<std::chrono::milliseconds>(getDuration()).count();
}
float CTimer::getSeconds() {
return std::chrono::duration_cast<std::chrono::milliseconds>(getDuration()).count() / 1000.f;
}
const std::chrono::steady_clock::time_point& CTimer::chrono() const {
return m_tpLastReset;
}