#include "gru_duration.h"
Functions | |
gru_duration_t | gru_duration_new () |
Creates an new duration object. | |
gru_duration_t | gru_duration_from_seconds (uint64_t seconds) |
Builds a duration struct that represents a duration. | |
gru_duration_t | gru_duration_from_minutes (uint64_t minutes) |
Builds a duration struct that represents a duration. | |
uint64_t | gru_duration_seconds (gru_duration_t duration) |
Given a duration object, return the number of seconds between its start and end time. | |
uint64_t | gru_duration_minutes (gru_duration_t duration, double *fractional) |
Given a duration object, return the number of minutes between its start and end time. | |
bool | gru_duration_parse (gru_duration_t *duration, const char *str) |
Parses a string containing a time representation with a suffix and returns its duration in relation to the current time. |
gru_duration_t gru_duration_from_minutes | ( | uint64_t | minutes | ) |
Builds a duration struct that represents a duration.
That means, the current time + the given number of minutes
minutes | the duration in minutes |
gru_duration_t gru_duration_from_seconds | ( | uint64_t | seconds | ) |
Builds a duration struct that represents a duration.
That means, the current time + the given number of seconds
seconds | the duration in seconds |
uint64_t gru_duration_minutes | ( | gru_duration_t | duration, | |
double * | fractional | |||
) |
Given a duration object, return the number of minutes between its start and end time.
duration | a duration object to calculate |
gru_duration_t gru_duration_new | ( | ) |
Creates an new duration object.
bool gru_duration_parse | ( | gru_duration_t * | out, | |
const char * | str | |||
) |
Parses a string containing a time representation with a suffix and returns its duration in relation to the current time.
The suffix may be 's' for seconds, 'm' for minutes, 'h' for hours or 'd' for days. There can be one or more suffixes (ie.: 1h15m, 1d1h)
out | parsed duration | |
str | string to parse (up to a maximum size of 63 bytes) |
uint64_t gru_duration_seconds | ( | gru_duration_t | duration | ) |
Given a duration object, return the number of seconds between its start and end time.
duration | a duration object to calculate |