Incorrect usage of wxInvalidDateTime ?

François Ingelrest athropos at gmail.com
Wed Nov 1 02:10:31 PST 2006


Hi,

I just switched from v2.6.1 to v2.6.3 (win32) and noticed some
assertions when running my app in debug mode. I managed to find the
"invalid" part of the code. This is the code I'm using:

wxDateTime aDate = wxInvalidDateTime;

/*

...

Some code that may assign a correct date to aDate

...

*/

if(aDate == wxInvalidDateTime)
{
    /*
        Some more code
    */
}

The assertion is caused by the test, as I found this in datetime.h (line 935):

inline bool operator==(const wxDateTime& dt) const
{
    wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
    return GetValue() == dt.GetValue();
}

Of course dt is invalid in my case, as it is how wxInvalidDateTime is defined!
I may change my code to use a pointer and the NULL value, but I don't
understand what wxInvalidDateTime is useful for if it can't be used in
tests?

I hope someone may be able to explain me how I should use wxInvalidDateTime.




More information about the wx-users mailing list