LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
time_api.h File Reference

Juno Time module API and common time math helpers. More...

#include "juno/macros.h"
#include "juno/status.h"
#include "juno/module.h"
#include "juno/types.h"
#include <stddef.h>
#include <stdint.h>
Include dependency graph for time_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  JUNO_TIMESTAMP_TAG
 Timestamp consisting of whole seconds and fixed-point subseconds. More...
 
struct  JUNO_TIME_API_TAG
 Vtable for time operations and conversions. More...
 

Macros

#define JunoTime_TimeApiInit(Now, SleepTo, Sleep)
 Initialize a JUNO_TIME_API_T literal with default math/conversion impls.
 

Typedefs

typedef struct JUNO_TIME_API_TAG JUNO_TIME_API_T
 
typedef struct JUNO_TIME_ROOT_TAG JUNO_TIME_ROOT_T
 
typedef struct JUNO_TIMESTAMP_TAG JUNO_TIMESTAMP_T
 
typedef uint32_t JUNO_TIME_SECONDS_T
 Whole seconds component type.
 
typedef uint64_t JUNO_TIME_MILLIS_T
 Milliseconds count type.
 
typedef uint64_t JUNO_TIME_MICROS_T
 Microseconds count type.
 
typedef uint64_t JUNO_TIME_NANOS_T
 Nanoseconds count type.
 
typedef uint32_t JUNO_TIME_SUBSECONDS_T
 Subsecond fixed-point fraction type.
 

Functions

struct JUNO_TIME_ROOT_TAG JUNO_MODULE_ROOT (JUNO_TIME_API_T, JUNO_MODULE_EMPTY)
 This is the Juno Time Module for all time time related operations.
 
 JUNO_MODULE_RESULT (JUNO_TIMESTAMP_RESULT_T, JUNO_TIMESTAMP_T)
 
 JUNO_MODULE_RESULT (JUNO_TIME_SECONDS_RESULT_T, JUNO_TIME_SECONDS_T)
 
 JUNO_MODULE_RESULT (JUNO_TIME_MILLIS_RESULT_T, JUNO_TIME_MILLIS_T)
 
 JUNO_MODULE_RESULT (JUNO_TIME_MICROS_RESULT_T, JUNO_TIME_MICROS_T)
 
 JUNO_MODULE_RESULT (JUNO_TIME_NANOS_RESULT_T, JUNO_TIME_NANOS_T)
 
 JUNO_MODULE_RESULT (JUNO_TIME_SUBSECONDS_RESULT_T, JUNO_TIME_SUBSECONDS_T)
 
JUNO_STATUS_T JunoTime_AddTime (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIMESTAMP_T *ptRetTime, JUNO_TIMESTAMP_T tTimeToAdd)
 Add a duration to a timestamp in-place.
 
JUNO_STATUS_T JunoTime_SubtractTime (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIMESTAMP_T *ptRetTime, JUNO_TIMESTAMP_T tTimeToSubtract)
 Subtract a duration from a timestamp in-place. If the subtraction would underflow (negative time), the result is saturated to 0 seconds and 0 subseconds, and JUNO_STATUS_INVALID_DATA_ERROR is returned.
 
JUNO_TIME_NANOS_RESULT_T JunoTime_TimestampToNanos (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIMESTAMP_T tTime)
 
JUNO_TIME_MICROS_RESULT_T JunoTime_TimestampToMicros (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIMESTAMP_T tTime)
 
JUNO_TIME_MILLIS_RESULT_T JunoTime_TimestampToMillis (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIMESTAMP_T tTime)
 
JUNO_TIMESTAMP_RESULT_T JunoTime_NanosToTimestamp (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIME_NANOS_T iNanos)
 
JUNO_TIMESTAMP_RESULT_T JunoTime_MicrosToTimestamp (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIME_MICROS_T iMicros)
 
JUNO_TIMESTAMP_RESULT_T JunoTime_MillisToTimestamp (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIME_MILLIS_T iMillis)
 
JUNO_RESULT_F64_T JunoTime_TimestampToDouble (const JUNO_TIME_ROOT_T *ptTime, JUNO_TIMESTAMP_T tTimestamp)
 
JUNO_TIMESTAMP_RESULT_T JunoTime_DoubleToTimestamp (const JUNO_TIME_ROOT_T *ptTime, double dTimestamp)
 
static bool JunoTime_TimestampGreaterThan (JUNO_TIMESTAMP_T tLeft, JUNO_TIMESTAMP_T tRight)
 Compare timestamps (tLeft > tRight).
 
static bool JunoTime_TimestampLessThan (JUNO_TIMESTAMP_T tLeft, JUNO_TIMESTAMP_T tRight)
 Compare timestamps (tLeft < tRight).
 
static bool JunoTime_TimestampEquals (JUNO_TIMESTAMP_T tLeft, JUNO_TIMESTAMP_T tRight)
 Compare timestamps for equality.
 
static JUNO_STATUS_T JunoTime_TimeInit (JUNO_TIME_ROOT_T *ptTime, const JUNO_TIME_API_T *ptApi, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvUserData)
 Initialize the time module root with API and failure handler.
 

Detailed Description

Juno Time module API and common time math helpers.