19#ifndef HEADER_TIME_HPP
20#define HEADER_TIME_HPP
30# define WIN32_LEAN_AND_MEAN
53 typedef time_t TimeType;
56 static void getDate(
int *day=NULL,
int *month=NULL,
int *year=NULL);
63 static std::string
toString(
const TimeType &tt);
72 GetSystemTimeAsFileTime(&ft);
73 __int64 t = ft.dwHighDateTime;
78# if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
79# define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
81# define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
83 t -= DELTA_EPOCH_IN_MICROSECS;
85 t |= ft.dwLowDateTime;
91 gettimeofday(&tv, NULL);
108 auto duration = std::chrono::steady_clock::now() -
m_mono_start;
110 std::chrono::duration_cast<std::chrono::milliseconds>(duration);
111 return value.count();
120 double diff = difftime(time1, time2);
146 static TimeType
addInterval(TimeType time,
int year,
int month,
int day) {
147 struct tm t = *gmtime(&time);
static std::string toString(const TimeType &tt)
Converts the time in this object to a human readable string.
Definition: time.cpp:69
static std::string getLogTime()
Get the time in string for game server logging prefix (thread-safe)
Definition: time.cpp:48
static uint64_t getMonoTimeMs()
Returns a time based since the starting of stk (monotonic clock).
Definition: time.hpp:106
static double getRealTime(long startAt=0)
Returns a time based on an arbitrary 'epoch' (e.g.
Definition: time.cpp:95
static void sleep(int msec)
Sleeps for the specified amount of time.
Definition: time.hpp:134
static std::chrono::steady_clock::time_point m_mono_start
Initalized when STK starts.
Definition: time.hpp:51
static irr::ITimer * m_timer
This objects keeps a copy of irrlicht's null-device timer.
Definition: time.hpp:48
static void init()
Init function for the timer.
Definition: time.cpp:39
static int compareTime(TimeType time1, TimeType time2)
Compare two different times.
Definition: time.hpp:118
static void getDate(int *day=NULL, int *month=NULL, int *year=NULL)
Returns the current date.
Definition: time.cpp:107
static TimeType getTimeSinceEpoch()
Returns the number of seconds since 1.1.1970.
Definition: time.hpp:68
static TimeType addInterval(TimeType time, int year, int month, int day)
Add a interval to a time.
Definition: time.hpp:146
Declares the general types that are used by the network.