I'm trying to modify hex code in a file that shows a date in a program.
I cannot figure out the code:
a5 c6 = 2017/04/05
3e c8 = 2017/08/14
7b c9 = 2017/11/31
What would be the hex code to display 2017/12/14
Any help greatly appreciated
Your dates don't make sense. Assuming the last figure is the day, and the one before is the month, there are not 31 days in November so the date is impossible. It doesn't work the other way either, since there are not 14 months.
Plesse igmore amd axxept applogies in adbance fir anu typos
Can you post the results of some sequential dates eg
Youre going to need to give us some more examples/data so we can reverse engineer the formula.
I'm going to guess that 5 bits store the day (32 values possible with 5 bits). 4 bits for the month. You then have 7 bits left over for the year. There'd be some epoc date/year for this too. 1950 maybe (you have up to 127 years you could store). Could be 1970. Could be something else entirely.
We know its not storing days since an epoc date and using function to calculate the date from that. Otherwise your single bit change would not have yielded an invalid date. You could try incrementing a bit at a time and see what dates come out. Probably find one or two more increments and either the month or the year would change (it may not be stored as day, month year. Could be day, year, month or any combination of!)
Is this some date the program displays when it runs, or are you trying to change some property the program uses?
Did a little bit more experimenting....
If you're running Windows open your calculater and set it to programming mode. Then type in the dates in YYYYMMDD format.
The values you gave us earlier then show these "decimal" to hex values:
2017/04/05 => 20170405 = 0x133C6A5
2017/08/14 => 20170814 = 0x133C83E
2017/11/31 => 20171131 = 0x133C97B
2017/11/30 => 20171130 = 0x133C97A
Those are the 4 dates you gave us with corresponding hex values. Observe that the last two bytes are month and day values, with the bytes simply swapped. I think your programme is storing the values as 4 bytes you've only been giving us the last two.
I would then guess your required value for 2017/12/14 is CEC9
Here's the working...
2017/12/14 => 20171214 => 0x133C9CE. Take the last two bytes (C9CE) and swap them to CEC9
You are bang on nzkc, it worked!! I remember experimenting with first byte values with C9 but must not have made it up to CE!
Thank you very much for taking the time to figure that out it will be a huge help both now and in the future, if you were around Wellington I would gladly buy you a beer, cheers!