Clk_NTP_DateTimeMake
Build a valid NTP epoch date/time structure.
Files
clk.h/clk.c
Prototype
CPU_BOOLEAN Clk_NTP_DateTimeMake (CLK_DATE_TIME *p_date_time,
CLK_YR yr,
CLK_MONTH month,
CLK_DAY day,
CLK_HR hr,
CLK_MIN min,
CLK_SEC sec,
CLK_TZ_SEC tz_sec);Arguments
p_date_time
Pointer to variable that will receive the date/time structure.
yr
Year value
[CLK_NTP_EPOCH_YR_START to CLK_NTP_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 is valid.
DEF_FAIL, otherwise.
Required Configuration
Available only if CLK_CFG_NTP_EN is DEF_ENABLED in clk_cfg.h (see Module Configuration).
Notes / Warnings
Date/time structure (p_date_time) must be representable in NTP timestamp. Thus date to convert must be greater than or equal to CLK_NTP_EPOCH_YR_START and less than CLK_NTP_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.
Example Usage
Listing - Clk_NTP_DateTimeMake() Example Usage
CLK_DATE_TIME date_time;
CPU_BOOLEAN valid;
/* 2010/09/18 11:11:11 UTC-05:00 */
valid = Clk_NTP_DateTimeMake(&date_time, 2010, 9, 18, 11, 11, 11, -18000);
if (valid == DEF_OK) {
printf("Date/time successfully created");
} else {
printf("Clock Date/time error\n\r");
}