From b1296f2c97c6fdc1c6a9922dc09c951b5cafdc12 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 29 Oct 2018 21:49:54 +0100 Subject: Initial commit --- src/Clock.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/Clock.cpp (limited to 'src/Clock.cpp') diff --git a/src/Clock.cpp b/src/Clock.cpp new file mode 100644 index 0000000..1dc9323 --- /dev/null +++ b/src/Clock.cpp @@ -0,0 +1,25 @@ +#include "../include/dchat/Clock.hpp" +#include + +namespace dchat +{ + static i64 getCurrentTimeMillis() + { + return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); + } + + Clock::Clock() + { + restart(); + } + + void Clock::restart() + { + startTime = getCurrentTimeMillis(); + } + + i64 Clock::getElapsedTimeMillis() const + { + return getCurrentTimeMillis() - startTime; + } +} \ No newline at end of file -- cgit v1.2.3