Give a timepoint for the current time.
Time is a goddamn nightmare, we are going to define our own time type
In Fleet, EVERYTHING is going to be stored as an unsigned long for ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
using time_ms = unsigned long;
using timept = std::chrono::high_resolution_clock::time_point;
timept now() {
return std::chrono::high_resolution_clock::now();
}
time_ms time_since(timept x) {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now()-x).
count();
}
timept tic_start;
time_ms tic_elapsed;
void tic() {
tic_elapsed = time_since(tic_start);
tic_start = now();
}
double elapsed_seconds() {
return tic_elapsed / 1000.0;
}
std::string datestring() {
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,80,"%Y-%m-%d %I:%M:%S",timeinfo);
return std::string(buffer);
}
Time conversions for fleet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Converts our own time format to ms, which is what Fleet's time utilities use The time format we accept is #+(.#+)[smhd] where shmd specifies seconds, minutes, hours days