Versions Compared

Key

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

...

Anchor10556541055654 Clk_UnixDateTimeMake() Anchor10556551055655Build a valid Unix epoch date/time structure. Anchor10556561055656

Files

...

clk.h/clk.c

...

Prototype

CLK_YR yr, CLK_MONTH month, CLK_DAY day, CLK_HR hr, CLK_MIN min, CLK_SEC sec, CLK_TZ_SEC tz_sec);
HTML Tablecode
Table Cell (td)
rowspan5
Anchor
10572191057219
classlanguageCode_Listing
Table Row (tr)
cpp
CPU_BOOLEAN  Clk_UnixDateTimeMake (CLK_DATE_TIME  *p_date_time,
Anchor
10572201057220
Anchor
10572211057221
Anchor
10572221057222
Anchor
10572231057223
Anchor
10572241057224
Anchor
10572251057225
Anchor
10556601055660
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)

...


                                   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.

anchoryr10701891070189 yr

Year value
[CLK_UNIX_EPOCH_YR_START to CLK_UNIX_EPOCH_YR_END).

Anchor10690251069025month month

Month value [CLK_MONTH_JAN to CLK_MONTH_DEC].

Anchor10690261069026 day day

Day value [1 to 31].

anchorhr10690271069027 hr

Hours value [0 to 23].

Anchor10690281069028 min min

Minutes value [0 to 59].

Anchor10690291069029sec sec

Seconds value [0 to 60].

...

tz_sec

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

...

Returned Values

...

10572591057259DEF_OK, if date/time structure successfully returned. Anchor10556731055673

DEF_FAIL, otherwise. Anchor10556741055674

Required Configuration

Anchor10617801061780Available only if CLK_CFG_UNIX_EN is DEF_ENABLED in clk_cfg.h (see section 3-1-1 Module Configuration). Anchor10556761055676

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.

Anchor10693721069372Day 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

Anchor
10556951055695Listing - Clk_UnixDateTimeMake() Example Usage

...

classCode_Listing

...

rowspan8

...

Listing - Clk_UnixDateTimeMake() Example Usage


CPU_BOOLEAN
valid;   /*
    valid;
 
                                      /* 2010/09/18   11:11:11 UTC-05:00  */
valid =

valid = Clk_UnixDateTimeMake(&date_time, 2010, 9, 18, 11, 11, 11, -18000);
if

if (valid == DEF_OK)
{
 {
    printf("Date/time successfully created");
} else {

} else {
    printf("Clock Date/time error\n\r");
}tr

}
Code Block
languagecpp
titleListing - Clk_UnixDateTimeMake() Example Usage
linenumberstrue
CLK_DATE_TIME  date_time;
Anchor
10573211057321
Anchor
10573221057322
Anchor
10573231057323
Anchor
10573241057324
Anchor
10573251057325
Anchor
10573261057326
Anchor
10573271057327
Anchor
10573281057328
Anchor
10556801055680
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)