Minor refactor
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
#include "timeutil.h"
|
||||
|
||||
using std::chrono::high_resolution_clock;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::microseconds;
|
||||
|
||||
timeutil::Timer::Timer() {
|
||||
start = high_resolution_clock::now();
|
||||
}
|
||||
int64_t timeutil::Timer::stop() {
|
||||
return duration_cast<microseconds>(high_resolution_clock::now()-start).count();
|
||||
}
|
||||
|
||||
float timeutil::time_value(float hour, float minute, float second) {
|
||||
return (hour + (minute + second / 60.0f) / 60.0f) / 24.0f;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
#ifndef UTIL_TIMEUTIL_H_
|
||||
#define UTIL_TIMEUTIL_H_
|
||||
|
||||
#include "../typedefs.h"
|
||||
#include <chrono>
|
||||
|
||||
namespace timeutil {
|
||||
class Timer {
|
||||
std::chrono::high_resolution_clock::time_point start;
|
||||
public:
|
||||
Timer();
|
||||
int64_t stop();
|
||||
};
|
||||
|
||||
float time_value(float hour, float minute, float second);
|
||||
void from_value(float value, int& hour, int& minute, int& second);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user