CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2005
    Posts
    1,828

    Problem with COleDateTime Status

    I am initializing a COleDateTime object with the current date like this, and its m_status is coming invalid. Can someone tell me the reason? This is the first time I've come across this kind of problem, while initializing COleDateTime with current time

    Code:
    COleDateTime dtInstalled = COleDateTime::GetCurrentTime();

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Problem with COleDateTime Status

    I never saw such a situation.
    Try to debug this code and see why the status is set to invalid.
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2005
    Posts
    1,828

    Re: Problem with COleDateTime Status

    yes while debugging only I saw when I initialize it, with current date, its m_status value comes out to be invalid and somewhere in net i checked out that anyone using Direct X 9 SDK is encountering this problem, which is consiered to be a bug, but i am unable to find no solution so as a temporary alternative I am using this condition

    Code:
    if (dtNow.m_status != COleDateTime::valid )
    	return 0;

  4. #4
    Join Date
    May 2002
    Posts
    1,435

    Re: Problem with COleDateTime Status

    Quote Originally Posted by maverick786us View Post
    yes while debugging only I saw when I initialize it, with current date, its m_status value comes out to be invalid...
    You are not understanding the suggestion to debug it. You need to step into the MFC source code and determine exactly where the call is failing. MFC uses various time-related functions (time(), GetLocalTime(), GetSystemTime(), GetTimeZoneInformation(), etc.) and somewhere in that source code you should be able to determine the point of failure and why it is happening.

  5. #5
    Join Date
    Apr 2005
    Posts
    1,828

    Re: Problem with COleDateTime Status

    Quote Originally Posted by 0xC0000005 View Post
    You are not understanding the suggestion to debug it. You need to step into the MFC source code and determine exactly where the call is failing. MFC uses various time-related functions (time(), GetLocalTime(), GetSystemTime(), GetTimeZoneInformation(), etc.) and somewhere in that source code you should be able to determine the point of failure and why it is happening.
    While debugging I noticed, right after initialization..

    Code:
    COleDateTime dtInstalled = COleDateTime::GetCurrentTime();
    It shows the value of m_status

    Code:
    dtInstalled = {m_dt=40203.667685185188 m_status=invalid }
    So this invalid value later in the code while making this kind of comparision

    Code:
    if(dtNow - dtInstalled > COleDateTimeSpan(120, 0, 0, 0))
    	return 0;
    Breaks the code thus causing debug assertion failure

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Problem with COleDateTime Status

    Quote Originally Posted by maverick786us View Post
    While debugging I noticed, right after initialization..

    Code:
    COleDateTime dtInstalled = COleDateTime::GetCurrentTime();
    It shows the value of m_status

    Code:
    dtInstalled = {m_dt=40203.667685185188 m_status=invalid }
    Did you step in (F11) the COleDateTime::GetCurrentTime() source code?
    Victor Nijegorodov

  7. #7
    Join Date
    Apr 2005
    Posts
    1,828

    Re: Problem with COleDateTime Status

    Quote Originally Posted by VictorN View Post
    Did you step in (F11) the COleDateTime::GetCurrentTime() source code?
    Yes while going inside at initialization (F11)

    Code:
    ATLCOMTIME_INLINE COleDateTime WINAPI COleDateTime::GetCurrentTime() throw()
    {
    	return COleDateTime(::_time64(NULL));
    }
    nothing happens, only after returning from this function it starts showing m_status invalid

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Problem with COleDateTime Status

    Did you step in the ctor COleDateTime(::_time64(NULL))?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured