CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Time Unit Conversion

Functions

int64 timeToSeconds (int64 time)
 
int64 timeFromSeconds (int64 seconds)
 
int64 timeToMsec (int64 time)
 
int64 timeFromMsec (int64 msec)
 
int64 timeFromRelTimespec (struct timespec *ts)
 
void timeToRelTimespec (struct timespec *ts, int64 time)
 
int64 timeFromAbsTimespec (struct timespec *ts)
 
void timeToAbsTimespec (struct timespec *ts, int64 time)
 
int64 timeFromTimeT (time_t tt)
 
time_t timeToTimeT (int64 time)
 

Detailed Description

Functions for converting between time units and external time formats.

Function Documentation

◆ timeFromAbsTimespec()

int64 timeFromAbsTimespec ( struct timespec *  ts)
inline

Convert a Unix absolute timespec to Julian epoch time.

Converts a POSIX timespec structure representing an absolute timestamp (seconds since Unix epoch: Jan 1, 1970) to microseconds since Julian epoch.

Unix epoch (Jan 1, 1970 00:00:00 UTC) corresponds to Julian date 2440587.50000, which is 210866760000000000 microseconds from the Julian epoch.

Parameters
tsPointer to timespec structure with Unix epoch timestamp
Returns
Time value in microseconds since Julian epoch

Definition at line 178 of file time.h.

◆ timeFromMsec()

int64 timeFromMsec ( int64  msec)
inline

Convert milliseconds to microseconds.

Parameters
msecTime value in milliseconds
Returns
Time value in microseconds

Definition at line 136 of file time.h.

◆ timeFromRelTimespec()

int64 timeFromRelTimespec ( struct timespec *  ts)
inline

Convert a relative timespec to microseconds.

Converts a POSIX timespec structure representing a relative time interval (not an absolute timestamp) to microseconds.

Parameters
tsPointer to timespec structure
Returns
Time interval in microseconds

Definition at line 148 of file time.h.

◆ timeFromSeconds()

int64 timeFromSeconds ( int64  seconds)
inline

Convert seconds to microseconds.

Parameters
secondsTime value in seconds
Returns
Time value in microseconds

Definition at line 120 of file time.h.

◆ timeFromTimeT()

int64 timeFromTimeT ( time_t  tt)
inline

Convert a Unix time_t to Julian epoch time.

Converts a standard C time_t value (seconds since Unix epoch: Jan 1, 1970) to microseconds since Julian epoch.

Parameters
tttime_t value
Returns
Time value in microseconds since Julian epoch

Definition at line 216 of file time.h.

◆ timeToAbsTimespec()

void timeToAbsTimespec ( struct timespec *  ts,
int64  time 
)
inline

Convert Julian epoch time to a Unix absolute timespec.

Converts a time value in microseconds since Julian epoch to a POSIX timespec structure representing seconds since Unix epoch (Jan 1, 1970).

Parameters
tsPointer to timespec structure to populate
timeTime value in microseconds since Julian epoch

Definition at line 201 of file time.h.

◆ timeToMsec()

int64 timeToMsec ( int64  time)
inline

Convert microseconds to milliseconds (truncating).

Parameters
timeTime value in microseconds
Returns
Time value in milliseconds

Definition at line 128 of file time.h.

◆ timeToRelTimespec()

void timeToRelTimespec ( struct timespec *  ts,
int64  time 
)
inline

Convert microseconds to a relative timespec.

Converts a time interval in microseconds to a POSIX timespec structure representing a relative time (not an absolute timestamp).

Parameters
tsPointer to timespec structure to populate
timeTime interval in microseconds

Definition at line 162 of file time.h.

◆ timeToSeconds()

int64 timeToSeconds ( int64  time)
inline

Convert microseconds to seconds (truncating).

Parameters
timeTime value in microseconds
Returns
Time value in seconds

Definition at line 112 of file time.h.

◆ timeToTimeT()

time_t timeToTimeT ( int64  time)
inline

Convert Julian epoch time to a Unix time_t.

Converts a time value in microseconds since Julian epoch to a standard C time_t value (seconds since Unix epoch).

Parameters
timeTime value in microseconds since Julian epoch
Returns
time_t value (seconds since Unix epoch)

Definition at line 230 of file time.h.