Paranoia

There are times I think I get Paranoid!

This is test code for the daylight saving time logic in Sol.

(Flipping from winter to summer with Date Time in control panel manually...)

If you can see anything I should check for ... let me know!

/////////////////////////////////////////////////////////////////////////////
void CTestDlg::CheckTimeLogic()
/////////////////////////////////////////////////////////////////////////////
{

// can I trust Bill to get this right?

COleDateTime TheDate(1999, 6, 6, 0, 15, 59);
COleDateTimeSpan AnHour(0,1,0,0);

TheDate -= AnHour;                   // summertime back an hour
ASSERT(TheDate.GetDay() == 5);
ASSERT(TheDate.GetHour() == 23);
ASSERT(TheDate.GetMinute() == 15);

COleDateTimeSpan HalfADay(0,12,0,0);
TheDate += HalfADay;                 // summertime forward a day
TheDate += HalfADay; // ..
ASSERT(TheDate.GetDay() == 6);
ASSERT(TheDate.GetHour() == 23);
ASSERT(TheDate.GetMinute() == 15);

TheDate += AnHour;                   // summertime forward an hour
ASSERT(TheDate.GetDay() == 7);
ASSERT(TheDate.GetHour() == 0);
ASSERT(TheDate.GetMinute() == 15);

// step back to January 20th - no daylight saving

for (int x = 0; x < 276; x++)
    TheDate -= HalfADay;

ASSERT(TheDate.GetMonth() == 1);
ASSERT(TheDate.GetDay() == 20);
ASSERT(TheDate.GetHour() == 0);
ASSERT(TheDate.GetMinute() == 15);

// 1999 is not a leap year
// so go to Year 2000

for (x = 0; x < 365; x++)
{
    TheDate += HalfADay;
    TheDate += HalfADay;
}

ASSERT(TheDate.GetMonth() == 1);
ASSERT(TheDate.GetDay() == 20);
ASSERT(TheDate.GetHour() == 0);
ASSERT(TheDate.GetMinute() == 15);

// 2000 is a leap year
// so go to Year 2001

for (x = 0; x < 366; x++)
{
    TheDate += HalfADay;
    TheDate += HalfADay;
}

ASSERT(TheDate.GetMonth() == 1);
ASSERT(TheDate.GetDay() == 20);
ASSERT(TheDate.GetHour() == 0);
ASSERT(TheDate.GetMinute() == 15);

TheDate -= AnHour; // Winter day flip

ASSERT(TheDate.GetMonth() == 1);
ASSERT(TheDate.GetDay() == 19);
ASSERT(TheDate.GetHour() == 23);
ASSERT(TheDate.GetMinute() == 15);

TheDate += HalfADay;                 // wintertime forward a day
TheDate += HalfADay;                 // ..
ASSERT(TheDate.GetDay() == 20);
ASSERT(TheDate.GetHour() == 23);
ASSERT(TheDate.GetMinute() == 15);

TheDate += AnHour;                   // wintertime forward an hour
ASSERT(TheDate.GetDay() == 21);
ASSERT(TheDate.GetHour() == 0);
ASSERT(TheDate.GetMinute() == 15);

ASSERT(TheDate.GetSecond() == 59);

// Yes I can trust Bill!

}


Back to Solar Energy Calculator Page