hi my timestamp is big endian therefore it is as it comes, thers no need for me to reverse the bytes. anyway i have to following code:
Code:
unsigned char _1,_2,_3,_4,_5,_6,_7,_8;
infile.read (&_1,sizeof (_1)) ;
infile.read (&_2,sizeof (_2)) ;
infile.read (&_3,sizeof (_3)) ;
infile.read (&_4,sizeof (_4)) ;
infile.read (&_5,sizeof (_5)) ;
infile.read (&_6,sizeof (_6)) ;
infile.read (&_7,sizeof (_7)) ;
infile.read (&_8,sizeof (_8)) ;
unsigned char unixtime [9];
unixtime[0]=_1;
unixtime[1]=_2;
unixtime[2]=_3;
unixtime[3]=_4;
unixtime[4]=_5;
unixtime[5]=_6;
unixtime[6]=_7;
unixtime[7]=_8;
unixtime[8]='/0';
std::string timestamp_s = unixtime;
std::stringstream converter(timestamp_s);
time_t timestamp;
converter >> std::hex >> timestamp;
struct tm t = *localtime(×tamp);
char buf[80];
if (strftime(buf, sizeof buf, "%a, %d %B %Y %H:%M:%S UTC", &t) == 0)
{
std::cerr << "Error calling strftime." << std::endl;
}
std::cout << buf << std::endl;
cout << buf << endl;
its gives me some strange results. In my unixtime array i am just storing each byte of my 8 byte time stamp in the order they should be translated. ANother strange thing that just started to happen is that my string terminating charcter for unixtime has started to give me garbage on the output, i dnt know if ive changed something without noticing?
I have started getting confused after the point of storing my bytes in the unixtime[]. If anyone ould guide me from this point to where i want to be i would be appreciative!