...
Files
clk.h/clk.c
Prototype
| Code Block |
|---|
|
CPU_BOOLEAN Clk_TS_NTP_ToDateTime (CLK_TS_SEC ts_ntp_sec,
CLK_TZ_SEC tz_sec,
CLK_DATE_TIME *p_date_time); |
Arguments
ts_ntp_sec
Timestamp to convert (in seconds, UTC+00).
...
Timestamp (ts_ntp_sec) must be set for UTC+00 and should not include the time zone offset (tz_sec) since Clk_TS_NTP_ToDateTime() includes the time zone offset in its date/time calculation. Thus the time zone offset should not be applied before or after calling Clk_TS_NTP_ToDateTime(). Time zone field of the date/time structure (p_date_time->TZ_sec) is set to the value of the time zone argument (tz_sec).
Example Usage
| Anchor |
|---|
| Listing - Clk_TS_NTP_ToDateTime() Example Usage |
|---|
| Listing - Clk_TS_NTP_ToDateTime() Example Usage |
|---|
|
| Code Block |
|---|
| language | cpp |
|---|
| title | Listing - Clk_TS_NTP_ToDateTime() Example Usage |
|---|
| linenumbers | true |
|---|
|
CLK_DATE_TIME date_time;
CLK_TS_SEC ts_ntp_sec;
CLK_TZ_SEC tz_sec;
CPU_BOOLEAN valid;
ts_ntp_sec = 1000000;
tz_sec = -5 * 3600;
valid = Clk_TS_NTP_ToDateTime(ts_ntp_sec, tz_sec, &date_time);
if (valid == DEF_OK) {
printf("Timestamp successfully converted\n\r");
} else {
printf("Timestamp conversion error\n\r");
} |