Date and Time Picker
-
Hey All, I am implementing the Date & Time Picker through MFC. I placed it on my dialog and assigned a variable to it...CDateTimeCtrl m_DateTime; I also added the event handler OnDtnCloseupDatetimepicker, and it works fine as long as I don't try to pick a date before Jan 1, 1970. If I pick a date before then, I get a Debug Assertion error on atltime.inl, Line 167, Expression: m_time != -1. I have never seen this before.... Here is the code that I have in the closeup function... void Measure1::OnDtnCloseupDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult) { m_DateTime.GetTime(time); int mnth = time.GetMonth(); switch(mnth) { case 1: Month = "January"; break; case 2: Month = "February"; break; case 3: Month = "March"; break; case 4: Month = "April"; break; case 5: Month = "May"; break; case 6: Month = "June"; break; case 7: Month = "July"; break; case 8: Month = "August"; break; case 9: Month = "September"; break; case 10: Month = "October"; break; case 11: Month = "November"; break; case 12: Month = "December"; break; } Day = time.GetDay(); Year = time.GetYear(); *pResult = 0; } Thanks in advance....
-
Hey All, I am implementing the Date & Time Picker through MFC. I placed it on my dialog and assigned a variable to it...CDateTimeCtrl m_DateTime; I also added the event handler OnDtnCloseupDatetimepicker, and it works fine as long as I don't try to pick a date before Jan 1, 1970. If I pick a date before then, I get a Debug Assertion error on atltime.inl, Line 167, Expression: m_time != -1. I have never seen this before.... Here is the code that I have in the closeup function... void Measure1::OnDtnCloseupDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult) { m_DateTime.GetTime(time); int mnth = time.GetMonth(); switch(mnth) { case 1: Month = "January"; break; case 2: Month = "February"; break; case 3: Month = "March"; break; case 4: Month = "April"; break; case 5: Month = "May"; break; case 6: Month = "June"; break; case 7: Month = "July"; break; case 8: Month = "August"; break; case 9: Month = "September"; break; case 10: Month = "October"; break; case 11: Month = "November"; break; case 12: Month = "December"; break; } Day = time.GetDay(); Year = time.GetYear(); *pResult = 0; } Thanks in advance....
I would guess that your time is a CTime. If so, the CTime object date limits are 1/1/1970 to 1/18/2038 (in VC6) and 1/1/1970 to 12/31/3000 in VC8 (2005). You could use COleDateTime for your time variable instead and that should solve your problem - it will handle dates from 1/1/100 to 12/31/9999. Hope that helps. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
Hey All, I am implementing the Date & Time Picker through MFC. I placed it on my dialog and assigned a variable to it...CDateTimeCtrl m_DateTime; I also added the event handler OnDtnCloseupDatetimepicker, and it works fine as long as I don't try to pick a date before Jan 1, 1970. If I pick a date before then, I get a Debug Assertion error on atltime.inl, Line 167, Expression: m_time != -1. I have never seen this before.... Here is the code that I have in the closeup function... void Measure1::OnDtnCloseupDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult) { m_DateTime.GetTime(time); int mnth = time.GetMonth(); switch(mnth) { case 1: Month = "January"; break; case 2: Month = "February"; break; case 3: Month = "March"; break; case 4: Month = "April"; break; case 5: Month = "May"; break; case 6: Month = "June"; break; case 7: Month = "July"; break; case 8: Month = "August"; break; case 9: Month = "September"; break; case 10: Month = "October"; break; case 11: Month = "November"; break; case 12: Month = "December"; break; } Day = time.GetDay(); Year = time.GetYear(); *pResult = 0; } Thanks in advance....