time_util.c File Reference

Time utility module implementation file. More...

#include "mcl_core/mcl_time_util.h"
#include "time_util.h"
#include "string_util.h"
#include "mcl_core/mcl_assert.h"
#include "mcl_core/mcl_memory.h"
Include dependency graph for time_util.c:

Go to the source code of this file.

Macros

#define GMTIME_R_EXISTS
 
#define TIMESTAMP_FIELD_COUNT   7
 
#define TIMESTAMP_DATE_INDEX   2
 

Functions

mcl_error_t mcl_time_util_convert_to_iso_8601_format (const time_t *time_value, char *iso8601_formatted_time)
 
mcl_bool_t mcl_time_util_validate_timestamp (const char *timestamp)
 
void time_util_get_time (mcl_time_t *current_time)
 

Detailed Description

Time utility module implementation file.

Definition in file time_util.c.

Macro Definition Documentation

#define GMTIME_R_EXISTS
Value:
((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE>= 1) || defined(_XOPEN_SOURCE) || \
defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || defined(_POSIX_SOURCE))

Definition at line 16 of file time_util.c.

#define TIMESTAMP_DATE_INDEX   2

Definition at line 20 of file time_util.c.

Referenced by mcl_time_util_validate_timestamp().

#define TIMESTAMP_FIELD_COUNT   7

Definition at line 19 of file time_util.c.

Referenced by mcl_time_util_validate_timestamp().

Function Documentation

mcl_error_t mcl_time_util_convert_to_iso_8601_format ( const time_t *  time_value,
char *  iso8601_formatted_time 
)

This function converts time value to ISO 8601 date and time format.

Parameters
[in]time_valueNumber of seconds passed since reference time.
[in,out]iso8601_formatted_timeTime representation in ISO 8601 format, buffer size must be at least MCL_TIMESTAMP_LENGTH.
Returns
  • MCL_OK in case of success.
  • MCL_FAIL in case of an internal error in MCL.

Definition at line 22 of file time_util.c.

References MCL_ASSERT_CODE_MESSAGE, MCL_DEBUG, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_NULL, MCL_NULL_CHAR, MCL_NULL_CHAR_SIZE, MCL_OK, and MCL_TIMESTAMP_LENGTH.

mcl_bool_t mcl_time_util_validate_timestamp ( const char *  timestamp)

This function validates timestamp in terms of format, length and time value.

Parameters
[in]timestampTimestamp value to be checked against yyyy-MM-ddTHH:mm:ss.SSSZ format. Ex:2016-04-26T08:06:25.317Z
Returns
  • MCL_TRUE in case timestamp is valid.
  • MCL_FALSE in case timestamp is not valid in terms of format, length or time value.

Definition at line 76 of file time_util.c.

References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_NULL, MCL_NULL_CHAR_SIZE, MCL_TIMESTAMP_LENGTH, MCL_TRUE, string_util_strlen(), string_util_strtol(), TIMESTAMP_DATE_INDEX, and TIMESTAMP_FIELD_COUNT.

Here is the call graph for this function:

void time_util_get_time ( mcl_time_t current_time)

This function returns the time elapsed in terms of seconds since Jan 1, 1970 UTC until now.

Parameters
[in]current_timeTime value in seconds.

Definition at line 129 of file time_util.c.

References MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.

Referenced by _create_self_issued_jwt_payload().

Here is the caller graph for this function: