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/MSP430F5659: mktime() still returns epoch UTC-6 after changing to 64-bit time_t

Part Number: MSP430F5659

Tool/software: Code Composer Studio

Problem: mktime() appears to be returning epoch time from Midnight (UTC-6) January 1 ,1970.

I'm not really sure how enabling 64 bit time_t resulted in a mix between posix time and ti-time. According to the Ti wiki on Time and clock RTS Functions, "__time64_t epoch is Jan 1, 1970 UTC-0000"

Is there something I'm missing on how to properly set up posix time? Below are all of the settings I can think of to be relevant.

Thanks,

Compiler Version: Version: TI v17.3.0

Code Composer Studio Version: 6.1.0.00104

Enable 64bit time_t: Project -> Properties -> (Show advanced Settings) -> C/C++ General -> Paths and Symbols -> Add -> Name = __TI_TIME_USES_64, Val = 1

C++ Code Snippet :

void datetime::setTime(uint16_t year, uint8_t mon, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec)
{
this->time.tm_year = static_cast<int>(year) - 1900; // Years since 1900
this->time.tm_mon = static_cast<int>(mon) - 1; // Convert [1-12] to [0-11]
this->time.tm_mday = static_cast<int>(day);
this->time.tm_hour = static_cast<int>(hour);
this->time.tm_min = static_cast<int>(min);
this->time.tm_sec = static_cast<int>(sec);

time_t temp = mktime(&this->time);
}

Notes:

  1. this->time is of type struct tm.
  2. Input year is from offset 0.
  3. Input mon has a range [1-12]
  4. All other inputs are compatible with struct tm

Input Values:

  1. year = 2017
  2. mon = 6
  3. day = 1
  4. hour = 12
  5. min = 0
  6. sec = 0

Output Values:

  1. temp - 1496340000 (GMT: Thursday, June 1, 2017 6:00:00 PM)
  2. year = 2017
  3. mon = 5
  4. day = 1
  5. hour = 12
  6. min = 0
  7. sec = 0