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. Need help developing algorithm

Need help developing algorithm

Scheduled Pinned Locked Moved C / C++ / MFC
helpalgorithms
5 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
    Steven M Hunt
    wrote on last edited by
    #1

    I am trying to create a time comparison algorithm, and i have had some issues with it. I was wondering if anyone out there has had a problem with this, or if anyone solved this problem. Any help would be appreciated. -- Steve

    C 1 Reply Last reply
    0
    • S Steven M Hunt

      I am trying to create a time comparison algorithm, and i have had some issues with it. I was wondering if anyone out there has had a problem with this, or if anyone solved this problem. Any help would be appreciated. -- Steve

      C Offline
      C Offline
      CillyMe
      wrote on last edited by
      #2

      What's a "time-comparison" algo? bEqual = CompareTime("23:00", "11:00 PM"); Or are you looking for a ready made time-comparison component? (I do not have the answer, just being noisy)

      S 1 Reply Last reply
      0
      • C CillyMe

        What's a "time-comparison" algo? bEqual = CompareTime("23:00", "11:00 PM"); Or are you looking for a ready made time-comparison component? (I do not have the answer, just being noisy)

        S Offline
        S Offline
        Steven M Hunt
        wrote on last edited by
        #3

        I'm trying to create a function similar to your CompareTime(). Basicly, the main issue is telling the difference between say 1:35:59 and say 1:36:05. I need a way for the computer to figure out that there is a 6 second difference between those 2. Once I can figure that out, the rest will be easy. -- Steve

        O RaviBeeR 2 Replies Last reply
        0
        • S Steven M Hunt

          I'm trying to create a function similar to your CompareTime(). Basicly, the main issue is telling the difference between say 1:35:59 and say 1:36:05. I need a way for the computer to figure out that there is a 6 second difference between those 2. Once I can figure that out, the rest will be easy. -- Steve

          O Offline
          O Offline
          Oinka
          wrote on last edited by
          #4

          you said it yourself, take the "difference" i.e. subtract one time from the other. If they're not in a form that allows arithmetic then convert them to such a form (there must be support for that). Maybe I'm not understanding your question... it's pretty vague.

          1 Reply Last reply
          0
          • S Steven M Hunt

            I'm trying to create a function similar to your CompareTime(). Basicly, the main issue is telling the difference between say 1:35:59 and say 1:36:05. I need a way for the computer to figure out that there is a 6 second difference between those 2. Once I can figure that out, the rest will be easy. -- Steve

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #5

            Use mktime() to obtain a time_t value from individual time fields, then use difftime(). Or you can roll your own algorithm like so:

            long differenceInSeconds
            (long nStartHour,
            long nStartMinute,
            long nStartSecond,
            long nEnd Hour,
            long nEndMinute,
            long nEndSecond)
            {
            long nStart = nStartHour*3600 + nStartMinute*60 + nStartSecond;
            long nEnd = nEndHour*3600 + nEndMinute*60 + nEndSecond;
            return (nEnd - nStart);
            }

            I hope you didn't make me do your homework. :(( (You're only cheating yourself, if you did). /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

            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