mistserver/lib/timing.h
2021-10-19 22:29:40 +02:00

20 lines
927 B
C++

/// \file timing.h
/// Utilities for handling time and timestamps.
#pragma once
#include <stdint.h>
#include <string>
namespace Util{
void wait(int64_t ms); ///< Sleeps for the indicated amount of milliseconds or longer.
void sleep(int64_t ms); ///< Sleeps for roughly the indicated amount of milliseconds.
uint64_t getMS(); ///< Gets the current time in milliseconds.
uint64_t bootSecs(); ///< Gets the current system uptime in seconds.
uint64_t unixMS(); ///< Gets the current Unix time in milliseconds.
uint64_t bootMS(); ///< Gets the current system uptime in milliseconds.
uint64_t getMicros(); ///< Gets the current time in microseconds
uint64_t getMicros(uint64_t previous); ///< Gets the time difference in microseconds.
uint64_t getNTP();
uint64_t epoch(); ///< Gets the amount of seconds since 01/01/1970.
std::string getUTCString(uint64_t epoch = 0);
}// namespace Util