44#define MAX_UNIT_LABELS 3
92 return tv->tv_sec * 1000000 + tv->tv_usec;
157 return (strftime(
buf, length,
"%s", &tm) == 0) ? -1 : 0;
165 struct tm tm = { 0, };
168 if (strptime(
str,
" %s", &tm) ==
NULL) {
String manipulation functions.
enum TIME_UNIT ast_time_str_to_unit(const char *unit)
Convert a string to a time unit enumeration value.
int ast_time_t_to_string(time_t time, char *buf, size_t length)
Returns a string representation of a time_t as decimal seconds since the epoch.
static struct time_unit_labels unit_labels[]
time_t ast_string_to_time_t(const char *str)
Returns a time_t from a string containing seconds since the epoch.
const char * second_labels[]
const char * day_labels[]
struct timeval ast_time_create(ast_time_t sec, ast_suseconds_t usec)
Create a timeval object initialized to given values.
struct timeval ast_time_create_by_unit(unsigned long val, enum TIME_UNIT unit)
Convert the given unit value, and create a timeval object from it.
const char * hour_labels[]
const char * minute_labels[]
const char * nanosecond_labels[]
struct timeval ast_time_create_by_unit_str(unsigned long val, const char *unit)
Convert the given unit value, and create a timeval object from it.
const char * millisecond_labels[]
ast_suseconds_t ast_time_tv_to_usec(const struct timeval *tv)
Convert a timeval structure to microseconds.
const char * year_labels[]
const char * week_labels[]
static struct timeval normalize_and_create(unsigned long usec)
Create a timeval first converting the given microsecond value into seconds and microseconds.
const unsigned int unit_labels_size
const char * month_labels[]
const char * microsecond_labels[]
Time-related functions and macros.
TIME_UNIT
Time units enumeration.
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.