Search code examples
datetimetimestamphexdecimalreverse-engineering

Reverse engineer 4 hex values to DateTime


Trying to reverse engineer 4 hex values to DateTime stamp from my heating system

I know that: 5F:A2:30:77 --> 2019.03-10 - 10:08 6D:A2:30:77 --> 2019.03-10 - 10:21

My first guess was that this was Unix timestamp, so converted the HEX to DEC and to a 32bit int = >

5F:A2:30:77 -> 1999675999 equivalent to 2033-05-14T09:33:19+00:00 in ISO 8601 6D:A2:30:77 -> 1999676013 equivalent to 2033-05-14T09:33:33+00:00 in ISO 8601

but unfortunately this does not work

hope that something has a good idea of how to convert this.

Thanks

//Kim


Solution

  • we have solved the riddle of this conversion :-).

    byte 1 = Minutes after midnight.
    byte 2 = Day of the month.
    byte 3 = Month.
    byte 4 = Number of years since 1900.
    
    # 2019.03.10 19:38
    stamp = int(0x7730A49A)
    time = stamp & 0b111111111111
    hours = int(time/60)
    minutes = time - (hours*60)
    day = (stamp >> 12) & 0xFF
    month = (stamp >> 20) & 0xF
    year = (stamp >> 24) + 1900
    

    Thanks to all who try to help.

    Case closed :-)