Clk_IsUnixDateTimeValid

Determine if date/time structure is representable in Unix epoch.

Files

clk.h/clk.c

Prototype

CPU_BOOLEAN  Clk_IsUnixDateTimeValid(CLK_DATE_TIME  *p_date_time);

Arguments

p_date_time

Pointer to variable that contains the date/time structure to validate.

Returned Values

DEF_YES, if date/time structure is valid.

DEF_NO, 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 Clock timestamp. Thus date to validate must be greater than or equal to CLK_UNIX_EPOCH_YR_START and less than CLK_UNIX_EPOCH_YR_END.

Example Usage

Listing - Clk_IsUnixDateTimeValid() Example Usage
CLK_DATE_TIME  date_time;
CPU_BOOLEAN    valid;
 
date_time.Yr      =   2010;     /* 2010/09/18  11:11:11 UTC-05:00  */
date_time.Month   =      9;
date_time.Day     =     18;
date_time.Hr      =     11;
date_time.Min     =     11;
date_time.Sec     =     11;
date_time.DayOfWk =      2;
date_time.DayOfYr =    291;
date_time.TZ_sec  = -18000;
 
valid = Clk_IsUnixDateTimeValid(&date_time);
if (valid == DEF_OK) {
    printf("Date/time is valid");
} else {
    printf("Date/time is NOT valid");
}