Need help developing algorithm
-
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
-
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
-
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)
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
-
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
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.
-
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
Use
mktime()
to obtain atime_t
value from individual time fields, then usedifftime()
. 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