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

Compare times

Scheduled Pinned Locked Moved C / C++ / MFC
help
6 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.
  • S Offline
    S Offline
    sireesha_sree
    wrote on last edited by
    #1

    Hi, I need to compare times which are strings. There is a structure for time. I don't have idea about that. Can u help out to compare times which are strings. Thanks

    CPalliniC N 2 Replies Last reply
    0
    • S sireesha_sree

      Hi, I need to compare times which are strings. There is a structure for time. I don't have idea about that. Can u help out to compare times which are strings. Thanks

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      You can: (1) Parse the strings and compare the respective integer values obtained. (2) Transform your string data (maybe via parsing again) to an opportune object (such a CTime instance if you're using MFC) and then using related members to perform comparison. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      In testa che avete, signor di Ceprano?

      S 1 Reply Last reply
      0
      • CPalliniC CPallini

        You can: (1) Parse the strings and compare the respective integer values obtained. (2) Transform your string data (maybe via parsing again) to an opportune object (such a CTime instance if you're using MFC) and then using related members to perform comparison. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        S Offline
        S Offline
        sireesha_sree
        wrote on last edited by
        #3

        Hi, I found one function strptime which converts string to time.I have included time.h and string.h header files . Even then i am getting the error 'strptime identifier not found;

        D CPalliniC 2 Replies Last reply
        0
        • S sireesha_sree

          Hi, I found one function strptime which converts string to time.I have included time.h and string.h header files . Even then i am getting the error 'strptime identifier not found;

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

          sireesha_sree wrote:

          I found one function strptime...

          Where? It does not appear to be part of MSVCRT.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          1 Reply Last reply
          0
          • S sireesha_sree

            Hi, I found one function strptime which converts string to time.I have included time.h and string.h header files . Even then i am getting the error 'strptime identifier not found;

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            sireesha_sree wrote:

            i am getting the error 'strptime identifier not found

            Because it isn't. Have a look at here [^]]. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • S sireesha_sree

              Hi, I need to compare times which are strings. There is a structure for time. I don't have idea about that. Can u help out to compare times which are strings. Thanks

              N Offline
              N Offline
              Nelek
              wrote on last edited by
              #6

              If you are in VC++, you can get the strings for the time like that: CTime time = CTime::GetCurrentTime(); CString szTime = time.Format ( "%A, %d.%B.%Y, %H:%M:%S" ); The CTime is a class and have methodes like: GetTime Returns a time_t that corresponds to this CTime object. GetYear Returns the year that this CTime object represents. GetMonth Returns the month that this CTime object represents (1 through 12). GetDay Returns the day that this CTime object represents (1 through 31). GetHour Returns the hour that this CTime object represents (0 through 23). GetMinute Returns the minute that this CTime object represents (0 through 59). GetSecond Returns the second that this CTime object represents (0 through 61). GetDayOfWeek Returns the day of the week (1 for Sunday, 2 for Monday, and so forth). If you are in c++ then use the struct time_t (in < time.h >) and isollate every member of the struct to compare them.

              Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?

              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