Zephyr Project API 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Time Representation APIs

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.
 
static void timespec_from_timeout (k_timeout_t timeout, struct timespec *ts)
 Convert a kernel timeout to a timespec.
 
static k_timeout_t timespec_to_timeout (const struct timespec *ts)
 Convert a timespec to a kernel timeout.
 

Detailed Description

Macro Definition Documentation

◆ TIME_UTILS_BASE_YEAR

#define TIME_UTILS_BASE_YEAR   1900

Function Documentation

◆ timespec_from_timeout()

static void timespec_from_timeout ( k_timeout_t  timeout,
struct timespec ts 
)
inlinestatic

#include <include/zephyr/sys/timeutil.h>

Convert a kernel timeout to a timespec.

This function converts time durations expressed as Zephyr k_timeout_t objects to struct timespec objects.

Parameters
timeoutthe kernel timeout to convert
[out]tsthe timespec to store the result

◆ timespec_to_timeout()

static k_timeout_t timespec_to_timeout ( const struct timespec ts)
inlinestatic

#include <include/zephyr/sys/timeutil.h>

Convert a timespec to a kernel timeout.

This function converts durations expressed as a struct timespec to Zephyr k_timeout_t objects.

Given that the range of a struct timespec is much larger than the range of k_timeout_t, and also given that the functions are only intended to be used to convert time durations (which are always positive), the function will saturate to K_NO_WAIT if the tv_sec field of ts is negative.

Similarly, if the duration is too large to fit in k_timeout_t, the function will saturate to K_FOREVER.

Parameters
tsthe timespec to convert
Returns
the kernel timeout

◆ timeutil_timegm()

time_t timeutil_timegm ( const struct tm tm)

#include <include/zephyr/sys/timeutil.h>

Convert broken-down time to a POSIX epoch offset in seconds.

Parameters
tmpointer to broken down time.
Returns
the corresponding time in the POSIX epoch time scale. If the time cannot be represented then (time_t)-1 is returned and errno is set to ERANGE`.
See also
http://man7.org/linux/man-pages/man3/timegm.3.html

◆ timeutil_timegm64()

int64_t timeutil_timegm64 ( const struct tm tm)

#include <include/zephyr/sys/timeutil.h>

Convert broken-down time to a POSIX epoch offset in seconds.

Parameters
tmpointer to broken down time.
Returns
the corresponding time in the POSIX epoch time scale.
See also
http://man7.org/linux/man-pages/man3/timegm.3.html