Hello Guys,
I've a file which is in some binary format I don't know, but I need to be able to read/write it. It contains data for given dates. I'm able to get the data part (some numbers for each days), but I couldn't figure out the dates.
Example (as it is in the file):
HEX, Decimal, Date Value (what it represents)
-----------------------
[66 5f 7f ff] (102,95,127,255) - (2002.05.30)
[66 5f ff ff] (102,95,255,255) - (2002.05.31)
So I need to know how I get the date values from the numbers.
I think it is written in reverse. I tried to convert it to Int32 and check the differences:
255,127,95,102 = 1717534719
255,255,95,102 = 1717567487
The difference is 32768, so that would make 1 day..., but unfortunately it's not always true (ie. I tested a year end example and it was not the case).
So, I would like to ask your help in figuring this out. How to convert it to DateTime and vice-verse.
Thanks,
Balazs
I've a file which is in some binary format I don't know, but I need to be able to read/write it. It contains data for given dates. I'm able to get the data part (some numbers for each days), but I couldn't figure out the dates.
Example (as it is in the file):
HEX, Decimal, Date Value (what it represents)
-----------------------
[66 5f 7f ff] (102,95,127,255) - (2002.05.30)
[66 5f ff ff] (102,95,255,255) - (2002.05.31)
So I need to know how I get the date values from the numbers.
I think it is written in reverse. I tried to convert it to Int32 and check the differences:
255,127,95,102 = 1717534719
255,255,95,102 = 1717567487
The difference is 32768, so that would make 1 day..., but unfortunately it's not always true (ie. I tested a year end example and it was not the case).
So, I would like to ask your help in figuring this out. How to convert it to DateTime and vice-verse.
Thanks,
Balazs
VulpesPosted Sep 13, 2011, 9:52 AM
The output should be:
Balazs FarkasPosted Sep 13, 2011, 10:05 AM
Balazs FarkasPosted Sep 13, 2011, 9:12 AM
Thanks.
VulpesPosted Sep 13, 2011, 8:56 AM
Of the remaining 3 bytes (24 bits):
The first 4 bits represents the month from 1 to 12;
The next 5 bits represents the day from 1 to 31;
The remaining 15 bits are unused and are all set to 1.
So 30th May would be encoded as:
01011111 01111111 11111111
or in hex : 5f 7f ff
31st May would be:
01011111 11111111 11111111
or in hex: 5f ff ff
and 3rd January would be:
00010001 11111111 11111111
or in hex: 11 ff ff
If you can give me a little time, I'll try and come up with some conversion routines to and from the .NET DateTime type.
Balazs FarkasPosted Sep 13, 2011, 8:21 AM
[65 11 ff ff] (101,17,255,255) - 2001.01.03
[65 12 7f ff] (101,18,127,255) - 2001.01.04
[65 12 ff ff] (101,18,255,255) - 2001.01.05
[65 13 7f ff] (101,19,127,255) - 2001.01.06
[65 13 ff ff] (101,19,255,255) - 2001.01.07
It looks like you were right. First one is the year since 1900. I think than it increasing the second one by 1 for every second day and flipping the third one between 255 and 127. What do you think?
It's just hard to believe that it's not some date format but some kind of code.
VulpesPosted Sep 13, 2011, 7:02 AM
Do you have the representations for a few other dates which might help us to figure out what it is.
A tentative theory is that 102 might be the number of years since 1900.