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:
- this->time is of type struct tm.
- Input year is from offset 0.
- Input mon has a range [1-12]
- All other inputs are compatible with struct tm
Input Values:
- year = 2017
- mon = 6
- day = 1
- hour = 12
- min = 0
- sec = 0
Output Values:
- temp - 1496340000 (GMT: Thursday, June 1, 2017 6:00:00 PM)
- year = 2017
- mon = 5
- day = 1
- hour = 12
- min = 0
- sec = 0