Versions Compared

Key

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

...

Anchor10513961051396 Clk_TS_NTP_ToDateTime() Anchor10513971051397Convert NTP timestamp to a date/time structure. Anchor10513981051398

Files

...

clk.h/clk.c

...

Prototype

1054370

                                    CLK_TZ_SEC      tz_sec,

                                    CLK_DATE_TIME  *p_date_time);
HTML Tablecode
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan5
Anchor
1054370
languagecpp
CPU_BOOLEAN  Clk_TS_NTP_ToDateTime (CLK_TS_SEC      ts_ntp_sec,
Anchor
10543711054371
Anchor
10514021051402
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)

...


...

Arguments

...

ts_ntp_sec

Timestamp to convert (in seconds, UTC+00).

...

tz_sec

Time zone offset (in seconds, ± from UTC).

...

10514131051413p_date_time

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

...

...

Returned Values

...

1054410DEF_OK, if timestamp successfully converted. Anchor10514151051415

DEF_FAIL, otherwise. Anchor10514161051416

Required Configuration

...

10616281061628Available only if CLK_CFG_NTP_EN is DEF_ENABLED in clk_cfg.h (see section 3-1-1 Module Configuration). Anchor10514181051418

Notes / Warnings

Anchor10691501069150Timestamp (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). Anchor10514371051437 Example Usage

...

classCode_Listing

...

rowspan8

...

Example Usage

Anchor
Listing - Clk_TS_NTP_ToDateTime() Example Usage
Listing - Clk_TS_NTP_ToDateTime() Example Usage


CLK_TS_SEC     ts_ntp_sec;

CLK_TZ_SEC     tz_sec;

CPU_BOOLEAN
valid;  
    valid;
 
ts_ntp_sec =   1000000;

tz_sec     = -5 * 3600;
valid =

valid      = Clk_TS_NTP_ToDateTime(ts_ntp_sec, tz_sec, &date_time);
if

if (valid == DEF_OK)
{ printf(“Timestamp successfully
 {
    printf("Timestamp successfully converted\n\
r”
r");
} else { printf(“Timestamp conversion

} else {
    printf("Timestamp conversion error\n\
r”
r");
}tr

}
Code Block
languagecpp
titleListing - Clk_TS_NTP_ToDateTime() Example Usage
linenumberstrue
CLK_DATE_TIME  date_time;
Anchor
10545291054529
Anchor
10544911054491
Anchor
10544581054458
Anchor
10544441054444
Anchor
10544651054465
Anchor
10544981054498
Anchor
10544511054451
Anchor
10544721054472
Anchor
10545481054548
Anchor
10545551054555
Anchor
10545621054562
Anchor
10545691054569
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)