Hello everybody, i have a problem with wich i struggled for the last 2-3 days. I have a simple Server application in wich i get data in a QByteArray variable i use the next line for this:
QByteArray Data = socket->readAll();
Then i output Data in hex format, to see that if what i get is the same with what the client sends me for this i do this:
qDebug() << “ Data in: “ << Data.toHex();
The output is this:
“a55a55aa010000000000000064000000028d0000b63d795100000000410100000000db6900000000000000000000000000000000000000008e00040000000000000000000003000000000300000000000001”
It’s exactly what i was expecting, so far so good, somewhere in this string i have three bytes wich gives me local time in UTC format starting from position 20 these are the values that i need: 63d795. So i figure that in order to acces those variables i’ll do this
utcTime = Data [23]
utcTime = utcTime << 8;
utcTime = utcTime + Data [22];
utcTime = utcTime << 8;
utcTime = utcTime + Data [21];
utcTime = utcTime << 8;
utcTime = utcTime + Data [20];
then i do this in order to format the date and time
QDateTime localTime(QDate(), QTime(), Qt::UTC);
localTime.setTime_t(abs(tempUtcTime));
qDebug() << localTime;
The clock shows the correct time at some point but when the third member respectivley Data [20] reaches 128 (0×80) it then changes the sign and starts counting -127…-126…..when it reaches 0 it works normally untill again reaches 128. I’m really blocked, i don’t know what to do further please help me
↧