Reputation: 133
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 EC 4F = 29/03/2009 - 17:15 7D 92 F3 16 = 30/03/2009 - 12:22 7D 92 FB 1A = 31/03/2009 - 12:26 7D 93 0B 01 = 01/04/2009 - 12:01 7D 93 12 88 = 02/04/2009 - 10:08 7D 93 1A 30 = 03/04/2009 - 08:48 7D 93 22 DD = 04/04/2009 - 11:29 7D 93 2A D5 = 05/04/2009 - 11:21
I cant figure out how to convert from the one to the other....
Anyone recognise the hex format?
Al
Upvotes: 6
Views: 12354
Reputation: 11
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;
}
Upvotes: 1
Reputation: 56792
12 bit year, 4 bit month (0-based), 5 bit day, 5 bit hour, 6 bit minute.
Nice puzzle :-)
Upvotes: 2
Reputation: 354694
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.
Upvotes: 12