Haka
Data Structures | Macros | Functions
time.h File Reference
#include <haka/types.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  time
 

Macros

#define TIME_BUFSIZE   27
 
#define INVALID_TIME   { 0, 0 }
 

Functions

void time_build (struct time *t, double secs)
 
bool time_gettimestamp (struct time *t)
 
void time_add (struct time *res, const struct time *t1, const struct time *t2)
 
int time_diff (struct time *res, const struct time *t1, const struct time *t2)
 
uint64 time_divide (const struct time *t1, const struct time *t2)
 
void time_mult (struct time *res, const struct time *t1, const int mult)
 
int time_cmp (const struct time *t1, const struct time *t2)
 
double time_sec (const struct time *t)
 
bool time_tostring (const struct time *t, char *buffer, size_t len)
 
bool time_format (const struct time *t, const char *format, char *buffer, size_t len)
 
bool time_isvalid (const struct time *t)
 

Detailed Description

Time representation.

Macro Definition Documentation

#define INVALID_TIME   { 0, 0 }

Static initializer for the struct time.

#define TIME_BUFSIZE   27

String buffer minimum size.

Function Documentation

void time_add ( struct time res,
const struct time t1,
const struct time t2 
)

Add two time object.

void time_build ( struct time t,
double  secs 
)

Build a new time structure from a number of seconds.

int time_cmp ( const struct time t1,
const struct time t2 
)

Compare two time object. It returns -1, 1 or 0 respectivelly if t1 is smaller than t2, t1 is larger than t2 or t1 is equal to t2.

int time_diff ( struct time res,
const struct time t1,
const struct time t2 
)

Compute the difference between two time object. It returns the result of time_cmp(t1, t2).

uint64 time_divide ( const struct time t1,
const struct time t2 
)

Divide two time value.

bool time_format ( const struct time t,
const char *  format,
char *  buffer,
size_t  len 
)

Convert time to a formated string.

See also
strftime()
bool time_gettimestamp ( struct time t)

Get a current timestamp.

bool time_isvalid ( const struct time t)

Check if the time is valid.

void time_mult ( struct time res,
const struct time t1,
const int  mult 
)

Multiply a time value.

double time_sec ( const struct time t)

Convert time to a number of seconds.

bool time_tostring ( const struct time t,
char *  buffer,
size_t  len 
)

Convert time to a string.

See also
TIME_BUFSIZE