Versions Compared

Key

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

...

Files

clk.h/clk.c

Prototype

Code Block
languagecpp
CPU_BOOLEAN  Clk_DateTimeToStr (CLK_DATE_TIME  *p_date_time,
                                CLK_STR_FMT     fmt,
                                CPU_CHAR       *p_str,
                                CPU_INT32U      str_len);


Arguments

p_date_time

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

...

The size of the string buffer that will receive the returned string address must be greater than or equal to CLK_STR_FMT_MAX_LEN.

Example Usage

Anchor
Listing - Clk_DateTimeToStr() Example Usage
Listing - Clk_DateTimeToStr() Example Usage

Code Block
languagecpp
titleListing - Clk_DateTimeToStr() Example Usage
linenumberstrue
CLK_DATE_TIME  date_time;
CPU_BOOLEAN    valid;
CPU_CHAR       str[CLK_STR_FMT_YYYY_MM_DD_HH_MM_SS_UTC_LEN];
 
                                  /* 2010/09/18   11:11:11 UTC-05:00  */
valid = Clk_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");
}
 
valid = Clk_DateTimeToStr(&date_time,
                           CLK_STR_FMT_YYYY_MM_DD_HH_MM_SS_UTC,
                           str,
                           CLK_STR_FMT_YYYY_MM_DD_HH_MM_SS_UTC_LEN);
if (valid == DEF_OK) {
    printf("Date/time = %s", str);
} else {
    printf("Clock Date/time to String error\n\r");
}