Date Time Picker Problem(IDC_DATETIMEPICKER)
-
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
-
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
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
-
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
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 }
-
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 }
A
CTime
object wraps a standard Ctime_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 -
A
CTime
object wraps a standard Ctime_t
. This type cannot represent a date before 1 January 1970, and the assertion is telling you this. Stability. What an interesting concept. -- Chris Maunderis there any method to resolve this problem? coz in my case I can't restrict input time to be after 1-1-1970
-
is there any method to resolve this problem? coz in my case I can't restrict input time to be after 1-1-1970
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)
-
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)
hi David, I tried your soluation, but the problem is still there, can you provide another simple sample? thanks
-
hi David, I tried your soluation, but the problem is still there, can you provide another simple sample? thanks
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)