SuperTuxKart
Loading...
Searching...
No Matches
Classes | Public Types | Static Public Member Functions | Static Private Attributes | List of all members
StkTime Class Reference

Classes

class  ScopeProfiler
 

Public Types

typedef time_t TimeType
 

Static Public Member Functions

static void init ()
 Init function for the timer.
 
static void getDate (int *day=NULL, int *month=NULL, int *year=NULL)
 Returns the current date.
 
static std::string getLogTime ()
 Get the time in string for game server logging prefix (thread-safe)
 
static std::string toString (const TimeType &tt)
 Converts the time in this object to a human readable string.
 
static TimeType getTimeSinceEpoch ()
 Returns the number of seconds since 1.1.1970.
 
static double getRealTime (long startAt=0)
 Returns a time based on an arbitrary 'epoch' (e.g.
 
static uint64_t getMonoTimeMs ()
 Returns a time based since the starting of stk (monotonic clock).
 
static int compareTime (TimeType time1, TimeType time2)
 Compare two different times.
 
static void sleep (int msec)
 Sleeps for the specified amount of time.
 
static TimeType addInterval (TimeType time, int year, int month, int day)
 Add a interval to a time.
 

Static Private Attributes

static irr::ITimer * m_timer = NULL
 This objects keeps a copy of irrlicht's null-device timer.
 
static std::chrono::steady_clock::time_point m_mono_start = std::chrono::steady_clock::now()
 Initalized when STK starts.
 

Member Function Documentation

◆ compareTime()

static int StkTime::compareTime ( TimeType  time1,
TimeType  time2 
)
inlinestatic

Compare two different times.

Returns
A signed integral indicating the relation between the time.

◆ getDate()

void StkTime::getDate ( int *  day = NULL,
int *  month = NULL,
int *  year = NULL 
)
static

Returns the current date.

Parameters
dayDay (1 - 31).
month(1-12).
year(4 digits).

◆ getMonoTimeMs()

static uint64_t StkTime::getMonoTimeMs ( )
inlinestatic

Returns a time based since the starting of stk (monotonic clock).

The value is a 64bit unsigned integer in milliseconds.

◆ getRealTime()

double StkTime::getRealTime ( long  startAt = 0)
static

Returns a time based on an arbitrary 'epoch' (e.g.

could be start time of the application, 1.1.1970, ...). The value is a double precision floating point value in seconds.

◆ getTimeSinceEpoch()

static TimeType StkTime::getTimeSinceEpoch ( )
inlinestatic

Returns the number of seconds since 1.1.1970.

This function is used to compare access times of files, e.g. news, addons data etc.

◆ init()

void StkTime::init ( )
static

Init function for the timer.

It grabs a copy of the timer of the current irrlicht device (which is the NULL device). This way the irrlicht time routine can be used even if no device exists. This situation can happen when the window resolution is changed - if the sfx manager (in a separate thread) would access the timer while the device does not exist, stk crashes.

◆ sleep()

static void StkTime::sleep ( int  msec)
inlinestatic

Sleeps for the specified amount of time.

Parameters
msecNumber of milliseconds to sleep.

Member Data Documentation

◆ m_timer

irr::ITimer * StkTime::m_timer = NULL
staticprivate

This objects keeps a copy of irrlicht's null-device timer.

This is important otherwise we can't get the time when resolution is switched (and the sfx threads needs real time at that time).


The documentation for this class was generated from the following files: