@eightlines wrote:
I'm doing a date countdown, and the code works on the Mac OS, but when moving over to the RPI (of 0.9.2, Raspbian Jessie) I think the lib ctime cannot be found and I get back 0 for all of my comparisons. Anyone know how I can link up ctime properly?
Update: ctime is loading but the result is always 0. My code:
#include <ctime> #define DELINIATION_DAY 86400 #define DELINIATION_HOUR 3600 #define DELINIATION_MIN 60 struct tm dest; struct tm now; time_t diff; dest.tm_year = 2016; dest.tm_mon = 8; dest.tm_mday = 17; dest.tm_hour = 19; dest.tm_min = 0; dest.tm_sec = 0; now.tm_year = ofGetYear(); now.tm_mon = ofGetMonth() - 1; now.tm_mday = ofGetDay(); now.tm_hour = ofGetHours(); now.tm_min = ofGetMinutes(); now.tm_sec = ofGetSeconds(); diff = difftime(mktime(&now), mktime(&dest)); sprintf(buf, "%02.0f", abs(floor(diff / DELINIATION_DAY))); string days(buf); sprintf(buf, "%03.0f", abs(floor(fmod(diff, DELINIATION_DAY)) / DELINIATION_HOUR)); string hours(buf); sprintf(buf, "%02.0f", abs(floor(fmod(fmod(diff, DELINIATION_DAY), DELINIATION_HOUR)) / DELINIATION_MIN)); string minutes(buf); sprintf(buf, "%02.0f", abs(floor(fmod(fmod(fmod(diff, DELINIATION_DAY), DELINIATION_HOUR), DELINIATION_MIN)))); string seconds(buf); cout << days << ", " << hours << " : " << minutes << " : " << seconds << endl;
Posts: 2
Participants: 1