OLE date and time format
hi this is sort of a follow on post from my previous one involving dates which you guys helped me with so much.
I have come across a timestamp stored in OLE format:
7C FE 2B 04
that string of hex contains the date 4/4/2008 19:30:44
does the time.h header allow any ways to convert this?
Do you mean the OLE automation date format as described here?
If so, I think we're in trouble; interpreting those 4 bytes as an IEEE float gives 1.05e37, which is somewhere in the year 2.87e34. If I try to go backwards, I get that the whole number part should be 39541=0x9a75, and I don't see that anywhere in your number.
So I think the problem is "what is OLE date format"?
im not sure what OLE format its in. I have a hex editor that has a handy little funtion that converts it for me. All i know is that when i took that string of the 4 hex bytes and put them into little endian order i got the right time and date.
Is OLE format going to be a nightmare to convert into a readble format?
is there no built in c++ functions?
and finally im not sure that i fully understand how the OLE function works. It stores days from 30/12/1899 is what i think it does?
Further research indicates that this is a double: so eight bytes not four. The whole thing should be 40 E3 4E BA 04 2B FE 7C which is 39541.813009259260 as a decimal which corresponds to 4/4/2008 19:30:44.
So to interpret, memcopy/reinterpret that eight-byte memory address as a double; the whole number part gives the day, multiply the fractional part to get the hour, multiply the fractional part of *that* multiplication by 60 to give the minutes, etc.
i dont know how you did it tabstop but the other bytes you came up with are the next ones in my file so whatever you did u where right!!
curiously though, how did you manage to get 39541.813009259260? reverse the bytes then invert the binary and view in decimal?
so in theory from then on there should have been 39541.8 days since 30/12/1899? and to get the rest i will have to preform the necessary calculations?
i am willing to do this however does the header time.h not offer anything that could preform this for me?
thanks very much for your help!
There is a hex/IEEE float converter you can find here. I figured out the 39541.whatever myself (years*365+leap days+days so far this year+etc), typed it in, noticed that it almost matched ('cause I had gotten carried away and did 7:30:30 instead) et voila.
There's nothing inside the standard time.h. If you're interfacing with OLE using a header, that header might have it. Someone somewhere has already written it, naturally, but it would be an OLE person, not a C person.
You can use VariantTimeToSystemTime() to convert an OLE date (double) to a SYSTEMTIME structure.
thank you for your advice! ive had a look at msdn and i think its just a case of implimenting it! haha, so hopefully should have it done in the next year or two! does it work similar to functions used in time.h?
i have my 8 bytes stored in
unsigned char time ;
but as regards to using the varienttimetosystemtime function im not sure i know to much on how to progress further. I think i need to get my time stored in a double rather then unsigned char to start.
My programming skills are very basic and i feel that i maybe starting to get out of my depth!