19 #ifndef HEADER_TIME_HPP
20 #define HEADER_TIME_HPP
30 # define WIN32_LEAN_AND_MEAN
34 # include <sys/time.h>
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);
67 static std::string
toString(
int year,
int month,
int day);
79 GetSystemTimeAsFileTime(&ft);
80 __int64 t = ft.dwHighDateTime;
85 # if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
86 # define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
88 # define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
90 t -= DELTA_EPOCH_IN_MICROSECS;
92 t |= ft.dwLowDateTime;
98 gettimeofday(&tv, NULL);
115 auto duration = std::chrono::steady_clock::now() -
m_mono_start;
117 std::chrono::duration_cast<std::chrono::milliseconds>(duration);
118 return value.count();
127 double diff = difftime(time1, time2);
153 static TimeType
addInterval(TimeType time,
int year,
int month,
int day) {
154 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:113
static double getRealTime(long startAt=0)
Returns a time based on an arbitrary 'epoch' (e.g.
Definition: time.cpp:124
static void sleep(int msec)
Sleeps for the specified amount of time.
Definition: time.hpp:141
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 std::string getDateFormat()
Obtains the translated format of the time string.
Definition: time.cpp:102
static int compareTime(TimeType time1, TimeType time2)
Compare two different times.
Definition: time.hpp:125
static void getDate(int *day=NULL, int *month=NULL, int *year=NULL)
Returns the current date.
Definition: time.cpp:136
static TimeType getTimeSinceEpoch()
Returns the number of seconds since 1.1.1970.
Definition: time.hpp:75
static TimeType addInterval(TimeType time, int year, int month, int day)
Add a interval to a time.
Definition: time.hpp:153
Declares the general types that are used by the network.