cTimestamp

Overview

Provides a struct and a set of function to work with a moment in time.

Types and Definitions

cTimestamp

struct cTimestamp
{
   int64_t _v;
};
typedef struct cTimestamp cTimestamp;

A cTimestamp value represents a moment in time.

Generated

cTimestampSlice

struct cTimestampSlice
{
int64_t s;
cTimestamp const* v;
};
typedef struct cTimestampSlice cTimestampSlice;

Via the macros SLICE_DEF_C_ and SLICE_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

/* init */
cTimestampSlice timestamp_slice_c( int64_t s, cTimestamp const* v );
cTimestampSlice make_timestamp_slice_c( cTimestamp const* beg,
                                        cTimestamp const* end );
cTimestampSlice empty_timestamp_slice_c( void );
/* sub */
cTimestampSlice left_timestamp_slice_c( cTimestampSlice slice, int64_t maxLen );
cTimestampSlice mid_timestamp_slice_c( cTimestampSlice slice, int64_t index );
cTimestampSlice right_timestamp_slice_c( cTimestampSlice slice,
                                         int64_t maxLen );
cTimestampSlice sub_timestamp_slice_c( cTimestampSlice slice,
                                       int64_t begIdx,
                                       int64_t endIdx);

cVarTimestampSlice

struct cVarTimestampSlice
{
int64_t s;
cTimestamp* v;
};
typedef struct cVarTimestampSlice cVarTimestampSlice;

Via the macros SLICE_DEF_C_ and SLICE_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

/* init */
cVarTimestampSlice var_timestamp_slice_c( int64_t s, cTimestamp* v );
cVarTimestampSlice make_var_timestamp_slice_c( cTimestamp* beg,
                                               cTimestamp* end );
cVarTimestampSlice empty_var_timestamp_slice_c( void );
/* sub */
cVarTimestampSlice left_var_timestamp_slice_c( cVarTimestampSlice slice,
                                               int64_t maxLen );
cVarTimestampSlice mid_var_timestamp_slice_c( cVarTimestampSlice slice,
                                              int64_t index );
cVarTimestampSlice right_var_timestamp_slice_c( cVarTimestampSlice slice,
                                                int64_t maxLen );
cVarTimestampSlice sub_var_timestamp_slice_c( cVarTimestampSlice slice,
                                              int64_t begIdx,
                                              int64_t endIdx);
/* var slice */
cVarTimestampSlice as_var_timestamp_slice_c( cVarTimestampSlice slice );
cVarTimestampSlice cast_var_timestamp_slice_c( cVarTimestampSlice slice,
                                               cTimestampSlice sub );
int64_t set_timestamp_slice_c( cVarTimestampSlice dst, cTimestampSlice src );

Functions

init

now_c

cTimestamp now_c( void );

Returns the actual moment in time.

null_timestamp_c

cTimestamp null_timestamp_c( void );

Returns an invalid moment in time.

cmp

cmp_timestamp_c

int cmp_timestamp_c( cTimestamp a, cTimestamp b );

Compares two timestamps and returns the three possible results:

<0

if a is earlier as b

0

if both dates are equal

>0

if a is later as b

eq_timestamp_c

bool eq_timestamp_c( cTimestamp a, cTimestamp b );

Returns true if both timestamps represent the same moment in time, otherwise false.

timestamp_is_valid_c

bool timestamp_is_valid_c( cTimestamp ts );

Returns true if the timespan represents a valid moment in time.

diff

between_timestamps_c

cDuration between_timestamps_c( cTimestamp a, cTimestamp b );

Returns the duration between two timestamps.

since_c

cDuration since_c( cTimestamp ts );

Returns the duration between the timestamp and now.

until_c

cDuration until_c( cTimestamp ts );

Returns the duration between now and the timestamp.