Hi, Ive used c++ in the past to convert unix time stamps but now I have a 64 bit time stamp to convert 'CB 6E 70 FE B9 C8 01 00' and im not sure how to go about this? is it a similar process to the unix way? Im a bit stuck
Hi, Ive used c++ in the past to convert unix time stamps but now I have a 64 bit time stamp to convert 'CB 6E 70 FE B9 C8 01 00' and im not sure how to go about this? is it a similar process to the unix way? Im a bit stuck
Where did that 64-bit time-stamp come from, and which UNIX way are you referring to?
my program basically examines a file which contains a 64 bit time stamp which I want to strip out of the file and display in a normal readable formatt. The time stamp spans from byte 2 to byte 10 of the file.
below is how ive converted time stamps before
Code: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;
Again, where did that come from? Knowing what type of file you're looking at would greatly aid us. Right now, we have a sequence of 8 bytes, and some time-converting code that I'm assuming gives the wrong answer.
- In what type of file you found these bytes, so we might look up format info.
- Is this big endian? little endian?
- What makes you think it's a timestamp, and do you know what date/time those bytes correspond to?
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
no probs,
its a Windows 64 bit time stamps stored in little endian formatt which resides inside a link file(shortcut file). Its basically the created date for the link file and I would like to convert this to a readable format
In that case, this is probably what you want: FileTimeToSystemTime()
thanks, Ive been having a look at this today wen i stuimbled across it earlier but if im honest I just dont know how to start it! I have my time stamp stored in my variable
char modifiedTime[]
I presume I somehow pass this to
FileTimeToSystemTime()
but I believe it need to be converted into some sort of time styructure for it to be correctly read?
then to display the date you print it out using the wYear, wDay........so on;
This link should show you the usage of FileTimeToSystemTime().
ssharish
You'd need to convert the timestamp string into a 64-bit int.
Here you see that the FILETIME struct has two DWORD numbers for the low and high part of the 64-bit value, so take half the timestamp string and convert it to a DWORD and store it in the high part, then take the other half, convert it and store it in the low part...
Hi Ive been having a look at that today and although i dont totally understand how to implement this totally I've had a go at the following code. It returns back one error so I'm hoping I mite be close, can you guys see where i may have gone wrong?
Code:char createdTime[] = {_ct1,_ct2,_ct3,_ct4,_ct5,_ct6,_ct7,_ct8,'\0'}; This contains my timestamp information stored from the file im processing DATE dt; memcpy(&dt, createdTime, sizeof(DATE)); SYSTEMTIME stime; FileTimeToSystemTime( dt, &stime ); // convert to structure cout << stime.wMonth << "/" << stime.wDay << "/ " << stime.wYear << " Time:" << stime.wHour<<":"<< stime.wMinute << ":"<<stime.wSecond <<"\n"; cout << "The created time is "<< createdTime << " "<< endl;
It would help if you told us the error you're getting, but I'm guessing it's because you're passing a DATE parameter to FileTimeToSystemTime() instead of the FILETIME parameter that it's expecting.
changing it to FILETIME i get the errors
cannot convert _FILETIME to const _FILETIME *
and
type mismatch in parameter lpfiletime
>cannot convert _FILETIME to const _FILETIME *
Did you try:
Code:FILETIME filetime; memcpy(&filetime, createdTime, sizeof(DATE)); FileTimeToSystemTime( &filetime, &stime ); // convert to structure
sorry to be a pain but I'm starting to get lost off as to what im doing now. I have the following code
Code:char createdTime[] = {_ct1,_ct2,_ct3,_ct4,_ct5,_ct6,_ct7,_ct8,'\0'}; //my time stamp /***************DO I NEED BOTH OF THESE?***************/ DATE dt; FILETIME filetime; /*******************************************************/ memcpy(&filetime, createdTime, sizeof(DATE)); //THE BELOW CODE IS WHERE I START TO GET THE ERRORS FileTimeToSystemTime( &filetime, &stime ); // convert to structure cout << stime.wMonth << "/" << stime.wDay << "/ " << stime.wYear << " Time:" << stime.wHour<<":"<< stime.wMinute << ":"<<stime.wSecond <<"\n";
The errors i now get is "pointer to overloaded function stime" and "type mismatch in lpsystemtime". I'm a little confused as to where stime comes from here
thank you for your patients