"Lee K" <no***@nothere.com> wrote...
This is not strictly a C++ issue but if anyone will know the answer its
you guys!
I am trying to figure out a date format stored in the registry by a piece
of software (I am trying to write something to enable me to script a
configuration). The program stores a createdate for a set of registry
keys held in a DWORD value. I assumed it would be the number of seconds since
epoch (1/1/1970 00:00:00) - but its not. Here is a couple of examples:
19/12/2002 11:41:38 = 764632371
13/12/2002 11:36:58 = 764239005
Any one have any other ideas????
Looks like your DWORD is a (<date> << 16) + <time>. Perhaps even
the regular packed MSDOS date and time values. Remember those?
bits:
Date: YYYYYYYMMMMDDDDD
Time: HHHHHMMMMMMSSSSS, where S is half of real seconds.
So, to calculate the date you need to do
void breakDate(DWORD dvalue, int& year, int& month, int& day,
int& hour, int& minute, int& sec)
{
year = (dvalue >> 25) + 1980;
month = (dvalue >> 21) & 0xf;
day = (dvalue >> 16) & 0x1f;
hour = (dvalue >> 11) & 0x1f;
minute = (dvalue >> 5) & 0x3f;
sec = (dvalue & 0x1f) * 2;
}
It's possible to have invalid values. Month can be more than 12,
day can be more than the nubmer of days in the month, hours could
be > 23, minutes can be > 59, seconds could be > 59.
Victor