Zephyr API 3.6.99
Loading...
Searching...
No Matches
timeutil.h File Reference

Utilities supporting operation on time data structures. More...

#include <time.h>
#include <zephyr/types.h>

Go to the source code of this file.

Data Structures

struct  timeutil_sync_config
 Immutable state for synchronizing two clocks. More...
 
struct  timeutil_sync_instant
 Representation of an instant in two time scales. More...
 
struct  timeutil_sync_state
 State required to convert instants between time scales. More...
 

Macros

#define TIME_UTILS_BASE_YEAR   1900
 

Functions

int64_t timeutil_timegm64 (const struct tm *tm)
 Convert broken-down time to a POSIX epoch offset in seconds.
 
time_t timeutil_timegm (const struct tm *tm)
 Convert broken-down time to a POSIX epoch offset in seconds.
 
int timeutil_sync_state_update (struct timeutil_sync_state *tsp, const struct timeutil_sync_instant *inst)
 Record a new instant in the time synchronization state.
 
int timeutil_sync_state_set_skew (struct timeutil_sync_state *tsp, float skew, const struct timeutil_sync_instant *base)
 Update the state with a new skew and possibly base value.
 
float timeutil_sync_estimate_skew (const struct timeutil_sync_state *tsp)
 Estimate the skew based on current state.
 
int timeutil_sync_ref_from_local (const struct timeutil_sync_state *tsp, uint64_t local, uint64_t *refp)
 Interpolate a reference timescale instant from a local instant.
 
int timeutil_sync_local_from_ref (const struct timeutil_sync_state *tsp, uint64_t ref, int64_t *localp)
 Interpolate a local timescale instant from a reference instant.
 
int32_t timeutil_sync_skew_to_ppb (float skew)
 Convert from a skew to an error in parts-per-billion.
 

Detailed Description

Utilities supporting operation on time data structures.

POSIX defines gmtime() to convert from time_t to struct tm, but all inverse transformations are non-standard or require access to time zone information. timeutil_timegm() implements the functionality of the GNU extension timegm() function, but changes the error value as EOVERFLOW is not a standard C error identifier.

timeutil_timegm64() is provided to support full precision conversion on platforms where time_t is limited to 32 bits.