/builddir/build/BUILD/gru-0.2.0/src/time/gru_duration.h File Reference
#include <math.h>
#include <stdlib.h>
#include <sys/time.h>
#include "common/gru_portable.h"
#include "gru_time_utils.h"
Go to the source code of this file.
Typedef Documentation
Function Documentation
gru_export 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
- Parameters:
-
| minutes | the duration in minutes |
- Returns:
- a duration object
gru_export 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
- Parameters:
-
| seconds | the duration in seconds |
- Returns:
- a duration object
gru_export 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.
- Parameters:
-
| duration | a duration object to calculate |
- Returns:
- the time difference in minutes
Creates an new duration object.
- Returns:
- a new duration object
gru_export 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)
- Parameters:
-
| out | parsed duration |
| str | string to parse (up to a maximum size of 63 bytes) |
- Returns:
- bool if successfully parse the string or false if it's not parseable or too large.
Given a duration object, return the number of seconds between its start and end time.
- Parameters:
-
| duration | a duration object to calculate |
- Returns:
- the time difference in seconds