Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Build a valid Unix epoch date/time structure.

Files

clk_cmd.h/clk_cmd.c

Prototype

Code Block
languagecpp
void  ClkCmd_Init(CLK_CMD_ERR  *p_err);


Arguments

p_

...

err

...

Pointer to variable that will receive the date/time structure.

yr

Year value 
[CLK_UNIX_EPOCH_YR_START to CLK_UNIX_EPOCH_YR_END).

month

Month value [CLK_MONTH_JAN to CLK_MONTH_DEC].

day

Day value [1 to 31].

hr

Hours value [0 to 23].

min

Minutes value [0 to 59].

sec

Seconds value [0 to 60].

tz_sec

Time zone offset (in seconds, ± from UTC) [-43200 to 43200].

Returned Values

DEF_OK, if date/time structure 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

Date/time structure (p_date_time) must be representable in Unix timestamp. Thus date to convert must be greater than or equal to CLK_UNIX_EPOCH_YR_START and less than CLK_UNIX_EPOCH_YR_END.

Day of week (p_date_time->DayOfWk) and Day of year (p_date_time->DayOfYr) are internally calculated and set in the date/time structure.

an error code which will be returned to your application:


CLK_CMD_ERR_NONE 
CLK_CMD_ERR_SHELL_INIT

Returned Values

None.

Notes / Warnings

None.

Example Usage

Anchor
Listing - ClkCmd_Init() Example Usage
Listing - ClkCmd_Init() Example Usage

Code Block
languagecpp
titleListing - ClkCmd_Init() Example Usage
linenumberstrue
CPU_BOOLEAN  success;
CLK_CMD_ERR  clk_cmd_err;
 
success = Shell_Init();
if (success == DEF_FAIL) {
    return;
}
  
ClkCmd_Init(&clk_cmd_err);
if (clk_cmd_err != CLK_CMD_ERR_NONE) {
    printf("ClkCmd module successfully initialized.");
} else {
    printf("ClkCmd module initialization error.");
}