DateTime hex format

后端 未结 3 1382
囚心锁ツ
囚心锁ツ 2020-12-09 23:48

I have the following know pair of hex values and dates:

7D 92 D2 5C = 26/03/2009 - 09:28
7D 92 DA CC = 27/03/2009 - 11:12
7D 92 E3 56 = 28/03/2009 - 13:22
7D 92 E         


        
相关标签:
3条回答
  • 2020-12-10 00:09

    i realize that this is an old topic, but i found it useful and thought i would add to it my 2 cents.

    u8 getMinutes(u32 in)
    {
        return in & 0x3f;
    }
    
    u8 getHours(u32 in)
    {
        return (in>>6) & 0x1f;
    }
    
    u8 getDays(u32 in)
    {
        return (in>>11) & 0x1f;
    }
    
    u8 getMonths(u32 in)
    {
        return ((in>>16)& 0xf)+1;
    }
    
    u16 getYears(u32 in)
    {
        return (in>>20) & 0x7ff;
    }
    
    void printDate(u32 in)
    {
        printf("%d/%d/%d - %d:%d", getDays(in), getMonths(in), getYears(in), getHours(in), getMinutes(in));
    }
    
    int main(int argc, char *argv[])
    {
        u32 t = 0x7D92D25C;
        printDate(t);
        return 0;
    }
    
    0 讨论(0)
  • 2020-12-10 00:11

    It's a simple bitfield, even though that's a pretty weird time format :)

    1111101100100101101001001011100
                             011100 - 28 minutes
                        01001       - 09 hours
                   11010            - 26 days
               0010                 - month 3 (zero-based, hence 2)
    11111011001                     - 2009 years

    would be my guess.

    0 讨论(0)
  • 2020-12-10 00:15

    12 bit year, 4 bit month (0-based), 5 bit day, 5 bit hour, 6 bit minute.

    Nice puzzle :-)

    0 讨论(0)
提交回复
热议问题