#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.
◆ gru_duration_t
◆ gru_duration_from_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_duration_from_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_duration_minutes()
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
◆ gru_duration_new()
Creates an new duration object.
- Returns
- a new duration object
◆ gru_duration_parse()
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.
◆ gru_duration_seconds()
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