This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TM4C1294NCPDT: Problem with localtime() function from time.h library

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hi,

I have a problem with the localtime function, until 02/28/2020 it decode the UNIX time correct. But after the date 02/29/2020 (leap day)

it adds one day. 

UNIXTime=1583020740  (02/29/2020 @ 11:59pm) converting with localtime() gives 01-03-20 23:59:00 (UTC)

UNIXTime=1614605651  (03/01/2021 @ 1:34pm) converting with localtime()  gives 02-03-20 23:59:00 (UTC)

The code is:

 UNIXTime=1582934340;  // 02/28/2020 @ 11:59pm (UTC)

  NTPinfo = localtime( &UNIXTime );
  Ur1_Seconds=NTPinfo->tm_sec;
  Ur1_Minutes=NTPinfo->tm_min;
  Ur1_Hours=NTPinfo->tm_hour;
  Ur1_Date=NTPinfo->tm_mday;
  Ur1_Month=NTPinfo->tm_mon+1;
  Ur1_Years=NTPinfo->tm_year-30;
  UARTprintf("Date/Time=%d: %02d-%02d-%02d %02d:%02d:%02d (GMT)\n\r",UNIXTime,Ur1_Date,Ur1_Month,Ur1_Years,Ur1_Hours,Ur1_Minutes,Ur1_Seconds);
 //                            Given date is correct: 28-02-20 23:59:00 (UTC)
Is there an issue with the localtime function?
Best Regards,
Henning Christiansen