Hello All,
I have a problem with difftime.
I have 2 strings containing a time. I must calculate the difference of this 2 strings into seconds.
This is my code:
double Seconds;
double Timeout;
unsigned char firsttime[8];
unsigned char secondtime[8];
char *timestr;
time_t first;
time_t second;
// check time out of 300 seconds between datwsh and WsDate
timestr= pTrxIn->DatWsh; //string with date time
memcpy(firsttim e,timestr+8,8); //timestring
timestr= pTrxIn->WsDate; //string with datetime
memcpy(secondti me,timestr+8,8) ; //timestring
first = (time_t)atol(fi rsttime);
second = (time_t)atol(se condtime);
Seconds = (difftime(secon d,first));
Timeout = atof(pTrxIn->TimeOut); //string containing "300"
if (Seconds > Timeout)
{
return "timeout reached";
}
return 0;
He gives me the time in 100? Not in 60?
I do somthing wrong, but what?
Regards,
Patrick
I have a problem with difftime.
I have 2 strings containing a time. I must calculate the difference of this 2 strings into seconds.
This is my code:
double Seconds;
double Timeout;
unsigned char firsttime[8];
unsigned char secondtime[8];
char *timestr;
time_t first;
time_t second;
// check time out of 300 seconds between datwsh and WsDate
timestr= pTrxIn->DatWsh; //string with date time
memcpy(firsttim e,timestr+8,8); //timestring
timestr= pTrxIn->WsDate; //string with datetime
memcpy(secondti me,timestr+8,8) ; //timestring
first = (time_t)atol(fi rsttime);
second = (time_t)atol(se condtime);
Seconds = (difftime(secon d,first));
Timeout = atof(pTrxIn->TimeOut); //string containing "300"
if (Seconds > Timeout)
{
return "timeout reached";
}
return 0;
He gives me the time in 100? Not in 60?
I do somthing wrong, but what?
Regards,
Patrick
Comment