Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Date Time Picker Problem(IDC_DATETIMEPICKER)

Date Time Picker Problem(IDC_DATETIMEPICKER)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdebuggingquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lonely_life
    wrote on last edited by
    #1

    I use VC++ 6.0 to make a MFC dialog based project, simply add a Date Timer Picker, using classwizard add two member variables for this datetimerpicker control(CTime, CDateTimeCtrl), then compile and run this simple application, ok, then interface comes out, datetimepicker is initialized to be 1970-1-1, when I reset time to be any time before 1970-1-1 I get this error message: Debug Assertion Failed Program: C:\test\debug\test.exe File: timecore.cpp Line: 40 what's wrong here? can anybody help me out? thanks

    M 1 Reply Last reply
    0
    • L lonely_life

      I use VC++ 6.0 to make a MFC dialog based project, simply add a Date Timer Picker, using classwizard add two member variables for this datetimerpicker control(CTime, CDateTimeCtrl), then compile and run this simple application, ok, then interface comes out, datetimepicker is initialized to be 1970-1-1, when I reset time to be any time before 1970-1-1 I get this error message: Debug Assertion Failed Program: C:\test\debug\test.exe File: timecore.cpp Line: 40 what's wrong here? can anybody help me out? thanks

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      What does line 40 in timecore.cpp say? --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer.   -- Michael P. Butler in the Lounge

      L 1 Reply Last reply
      0
      • M Michael Dunn

        What does line 40 in timecore.cpp say? --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer.   -- Michael P. Butler in the Lounge

        L Offline
        L Offline
        lonely_life
        wrote on last edited by
        #3

        line 40 of timecore.cpp is ASSERT(m_time != -1); // indicates an illegal input time inside this constructor CTime::CTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, int nDST) { struct tm atm; atm.tm_sec = nSec; atm.tm_min = nMin; atm.tm_hour = nHour; ASSERT(nDay >= 1 && nDay <= 31); atm.tm_mday = nDay; ASSERT(nMonth >= 1 && nMonth <= 12); atm.tm_mon = nMonth - 1; // tm_mon is 0 based ASSERT(nYear >= 1900); atm.tm_year = nYear - 1900; // tm_year is 1900 based atm.tm_isdst = nDST; m_time = mktime(&atm); ASSERT(m_time != -1); // indicates an illegal input time }

        M 1 Reply Last reply
        0
        • L lonely_life

          line 40 of timecore.cpp is ASSERT(m_time != -1); // indicates an illegal input time inside this constructor CTime::CTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, int nDST) { struct tm atm; atm.tm_sec = nSec; atm.tm_min = nMin; atm.tm_hour = nHour; ASSERT(nDay >= 1 && nDay <= 31); atm.tm_mday = nDay; ASSERT(nMonth >= 1 && nMonth <= 12); atm.tm_mon = nMonth - 1; // tm_mon is 0 based ASSERT(nYear >= 1900); atm.tm_year = nYear - 1900; // tm_year is 1900 based atm.tm_isdst = nDST; m_time = mktime(&atm); ASSERT(m_time != -1); // indicates an illegal input time }

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          A CTime object wraps a standard C time_t. This type cannot represent a date before 1 January 1970, and the assertion is telling you this. Stability. What an interesting concept. -- Chris Maunder

          L 1 Reply Last reply
          0
          • M Mike Dimmick

            A CTime object wraps a standard C time_t. This type cannot represent a date before 1 January 1970, and the assertion is telling you this. Stability. What an interesting concept. -- Chris Maunder

            L Offline
            L Offline
            lonely_life
            wrote on last edited by
            #5

            is there any method to resolve this problem? coz in my case I can't restrict input time to be after 1-1-1970

            D 1 Reply Last reply
            0
            • L lonely_life

              is there any method to resolve this problem? coz in my case I can't restrict input time to be after 1-1-1970

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              This works fine for me:

              COleDateTime from(1968, 9, 6, 16, 10, 0),
              to(2006, 4, 29, 16, 23, 15);
              m_datetime.SetRange(&from, &to);


              "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

              L 1 Reply Last reply
              0
              • D David Crow

                This works fine for me:

                COleDateTime from(1968, 9, 6, 16, 10, 0),
                to(2006, 4, 29, 16, 23, 15);
                m_datetime.SetRange(&from, &to);


                "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                L Offline
                L Offline
                lonely_life
                wrote on last edited by
                #7

                hi David, I tried your soluation, but the problem is still there, can you provide another simple sample? thanks

                D 1 Reply Last reply
                0
                • L lonely_life

                  hi David, I tried your soluation, but the problem is still there, can you provide another simple sample? thanks

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Perhaps I do not understand the problem. The code snippet I provided gives the control a minimum date of 6-Sep-1968, which is earlier than the 1-Jan-1970 date that was originally confining you. If you have a relevant code snippet that we could look at, we might be of more help.


                  "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups