Clk_GetTS_Unix
Get current Clock timestamp as a Unix timestamp.
Files
clk.h/clk.c
Prototype
CPU_BOOLEAN Clk_GetTS_Unix (CLK_TS_SEC *p_ts_unix_sec);
Arguments
p_ts_unix_sec
Pointer to variable that will receive the Unix timestamp:
In seconds UTC+00, if no errors;CLK_TS_SEC_NONE
, otherwise.
Returned Values
DEF_OK
, if timestamp successfully returned.
DEF_FAIL
, otherwise.
Required Configuration
Available only if CLK_CFG_UNIX_EN
is DEF_ENABLED
in clk_cfg.h
(see Module Configuration).
Notes / Warnings
Unix timestamp does not include any time zone offset. Thus any local time zone offset must be applied after calling Clk_GetTS_Unix()
.
Unix timestamp will eventually overflow, thus it's not possible to get Unix timestamp for years on or after CLK_UNIX_EPOCH_YR_END
.
Example Usage
Listing - Clk_GetTS_Unix() Example Usage
CLK_TS_SEC ts_unix_sec; CPU_BOOLEAN valid; valid = Clk_GetTS_Unix(&ts_unix_sec); if (valid == DEF_OK) { printf("Timestamp Unix = %u", ts_unix_sec); } else { printf("Get TS Unix error\n\r"); }