CTime::GetSecond()
-
For the life of me I can't get this function to not crash my program. CTime somecoolvariablename, anothercoolvariablename; somecoolvariablename.GetCurrentTime(); // do something anothercoolvariablename.GetCurrentTime(); if(anothercoolvariablename.GetSecond() - somecoolvariablename.GetSecond() > 10) // CRASH HERE! MessageBox(yadda yadda yadda); I've tried it in as many contexts as possible, it always crashes. I tried using CTimeSpan, it doesn't wanna work for me either! CTimeSpan supervar; // do something if(supervar.GetTotalSeconds() > 10) MessageBox(yadda yadda yadda); I must be missing something simple.... - John
-
For the life of me I can't get this function to not crash my program. CTime somecoolvariablename, anothercoolvariablename; somecoolvariablename.GetCurrentTime(); // do something anothercoolvariablename.GetCurrentTime(); if(anothercoolvariablename.GetSecond() - somecoolvariablename.GetSecond() > 10) // CRASH HERE! MessageBox(yadda yadda yadda); I've tried it in as many contexts as possible, it always crashes. I tried using CTimeSpan, it doesn't wanna work for me either! CTimeSpan supervar; // do something if(supervar.GetTotalSeconds() > 10) MessageBox(yadda yadda yadda); I must be missing something simple.... - John
-
For the life of me I can't get this function to not crash my program. CTime somecoolvariablename, anothercoolvariablename; somecoolvariablename.GetCurrentTime(); // do something anothercoolvariablename.GetCurrentTime(); if(anothercoolvariablename.GetSecond() - somecoolvariablename.GetSecond() > 10) // CRASH HERE! MessageBox(yadda yadda yadda); I've tried it in as many contexts as possible, it always crashes. I tried using CTimeSpan, it doesn't wanna work for me either! CTimeSpan supervar; // do something if(supervar.GetTotalSeconds() > 10) MessageBox(yadda yadda yadda); I must be missing something simple.... - John
The problem come from the fact that you're using GetCurrentTime() in the wrong way; it is a static function that returns a CTime object filled with the current time. Therefore, the following code should work: CTime somecoolvariablename, anothercoolvariablename; somecoolvariablename = CTime::GetCurrentTime(); // do some work anothercoolvariablename = CTime::GetCurrentTime(); if(anothercoolvariablename.GetSecond() - somecoolvariablename.GetSecond() > 10) // CRASH HERE! MessageBox(yadda yadda yadda);