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 and Time Picker

Date and Time Picker

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelp
3 Posts 3 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.
  • G Offline
    G Offline
    goodoljosh1980
    wrote on last edited by
    #1

    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....

    K D 2 Replies Last reply
    0
    • G goodoljosh1980

      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....

      K Offline
      K Offline
      krmed
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • G goodoljosh1980

        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....

        D Offline
        D Offline
        Dy
        wrote on last edited by
        #3

        goodoljosh1980 wrote:

        m_DateTime.GetTime(time);

        Is 'time' a CTime object? If it is, it's limited to January 1st, 1970 to January 18th, 2038. Try a COleDateTime object instead, it has a range of January 1st, 100 to December 31st, 9999.


        - Dy

        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