Tuesday, September 07, 2010

Time Management, Conversion of system time to CTime


CTime Class

8 bytes, with an upper limit of January 18, 2038.


Time Management

#define _BASE_YEAR 70L /* 1970 is the base year */
#define _MAX_YEAR 138: /* 2038 is the max year */

Note that the _make__time64_t() function insist that the year is between 1969 and 2038.  If it is not a error value of 22 is set and a value of -1 is returned.

This is slight inconsistent with the behavior of CTime which set the time to 1970 is the time is earlier than 1900 and than creates the CTime from system time with no error.

This is a know bug.

atltime.inl

if (sysTime.wYear < 1900)
{
   __time64_t time0 = 0L;
   CTime timeT(time0);
   ...
}
else
{
   CTime timeT(
      (int) sysTime.wYear, (int)sysTime,wMonth, (int) sysTime.wDay,
      (int) sysTime.wHour, (int)sysTime.wMinute, (int) sysTime,wSecond,
      nDST);
   ...
}

The SYSTEMTIME structure does have milliseconds, but it is not used by CTime.

::VariantTimeToSystemTime() also seem to be dropping the milliseconds.

No comments: