EDITED
Sorry, this is not a solution , only some starting point , if someone has more time to touch the depth.
The stored "hidden" number for the first date should be:
import datetime from datetime import datetime, timedelta GPS_EPOCH = datetime(1980, 1, 6) date_1 = datetime(2012,10,04, 01,00,51,759) d=(date_1 - GPS_EPOCH) ( d.days * 24 * 60 * 60 + d.seconds ) * 1000 + d.microseconds ----> 1.033.347.651.759 <----
But the number you get decompresses the first hexadecimal data code:
struct.unpack('q', "\xBF\x13\xDB\x79\xC0\x00\x00\x00" )[0] ----> 826.678.121.407 <----
Note that I move \ xBF to the position with the least significant digit. I do this because in your example 1 millisecond is \ xC0 - \ xBF. The least significant digit seems to be \ xBF in the first example.
Then for your sample data, the formula could be:
milliseconds = ( 1033347651759 - 826678121407 ) + unpack_your_string_with_offset GPS_EPOCH + milliseconds
Testing with less data ...
>>> milliseconds = ( 1033347651759 - 826678121407 ) + \ struct.unpack('q', "\xBF\x13\xDB\x79\xC0\x00\x00\x00" )[0] >>> >>> GPS_EPOCH + timedelta( milliseconds = milliseconds) datetime.datetime(2012, 10, 4, 1, 0, 51, 759000)
Please post more sample data and expected results to test or develop a new formula.
I took the unpacking method from @leon_matthews: +1;)
I hope some solution Raiman finds a solution. I will follow your answer.