Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Unable to render {include} The included page could not be found.
Unable to render {include} The included page could not be found.

Clk_TS_UnixToTS()

Convert Unix timestamp to Clock timestamp.

Files

clk.h/clk.c

Prototype

CPU_BOOLEAN Clk_TS_UnixToTS (CLK_TS_SEC *p_ts_sec,

CLK_TS_SEC ts_unix_sec);

Arguments

p_ts_sec Pointer to variable that will receive the Clock timestamp:

In seconds UTC+00, if no errors;
CLK_TS_SEC_NONE, otherwise.

ts_unix_sec Unix timestamp value to convert (in seconds, UTC+00).

Returned Values

DEF_OK, if timestamp successfully converted.

DEF_FAIL, otherwise.

Required Configuration

Available only if CLK_CFG_UNIX_EN is DEF_ENABLED in clk_cfg.h (see section 3-1-1).

Notes / Warnings

Returned timestamp does not include any time zone offset. Thus any local time zone offset should be applied before or after calling Clk_TS_UnixToTS().

Only years supported by Clock and Unix can be converted, thus the timestamp date must be greater than or equal to CLK_EPOCH_YR_START and less than CLK_UNIX_EPOCH_YR_END.

Example Usage

CLK_TS_SEC ts_sec;

CLK_TS_SEC ts_unix_sec

CPU_BOOLEAN valid;

 

ts_unix_sec = 1000000;

valid = Clk_TS_UnixToTS(&ts_sec, ts_unix_sec);

if (valid == DEF_OK) {

printf("Timestamp = %u", ts_sec);

} else {

printf("Convert timestamp error\n\r");

}

  • No labels