python - Extracting date and time from a binary data string using -



python - Extracting date and time from a binary data string using -

i have 3rd party application stores time series info packed binary file. trying create tool convert info stored in file.

shown below snapshot of data.

41 16 00 00 01 00 d7 11 00 00 01 00 e8 55 a6 20 08 1e d0 08 00 00 00 60 59 d5 86 40 03 e8 f5 2c 22 08 1e d0 08 00 00 00 00 c0 0b 87 40 01 e8 95 b3 23 08 1e d0 08 00 00 00 40 1e 00 87 40 01 e8 35 3a 25 08 1e d0 08 00 00 00 60 13 f8 86 40 01 e8 d5 c0 26 08 1e d0 08 00 00 00 40 65 09 87 40 01 e8 75 47 28 08 1e d0 08 00 00 00 20 8a f6 86 40 01 e8 15 ce 29 08

i know block of info corresponds next values.

5/13/2013 17:46:11.558 730.6686401 5/13/2013 17:46:14.118 737.46875 5/13/2013 17:46:16.678 736.0147705

i can extract values: of type double. instance, 8 bytes 00 00 00 60 59 d5 86 40 correspond 730.6686401.

but stumped how extract datetime format. know buried in string somewhere. how can figure out format time in?

i have been using python's struct module type conversion.

anybody have ideas?

if take 8 bytes before 1 of double, , consider integer (low-endian, double), next numbers:

635040567715583464 635040567741183464 635040567766783464

if split these numbers 10**7, date number of seconds (and fractional seconds). @ to the lowest degree corresponds in minutes, seconds, , fractions of seconds. hours off-by-two error (timezone?). finish date, day number 735000(*) corresponds 5/13/2013 follows. it's number of days year 1:

>>> datetime.date(1,1,1) + datetime.timedelta(735000) datetime.date(2013, 5, 13)

(*) that's of these numbers divided 10**7 * 60 * 60 * 24

or in single step:

>>> x = 635040567715583464 / 10.**7 / 86400 >>> datetime.datetime(1,1,1) + datetime.timedelta(x) datetime.datetime(2013, 5, 13, 15, 46, 11, 558353)

python datetime struct reverse-engineering

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -