September 12th, 2003, 10:48 AM
I am using C and I have 2 times stored in time_t variables. I am trying to see if the one time is greater than the other. I figured I would use the difftime function and if it returned a negative number then the time was less than the other, if it returned positive then the time was greater than the other. The problem is that difftime() is taking the absolute value of the difference in time. So it will never return a negative value. Is there another way of doing this?
I dont really understand how time is represented in a time_t variable. It is a long integer correct? But when I look at the two different times ,say time1 is 8:21:02 and time2 8:28:14, in debug mode it shows time1 1060950062 and time2 1060950494. Why isnt time2 a larger number than time1?
Is there a function that will compare 2 tm variables? I couldnt find one.
September 12th, 2003, 11:48 AM
>> Why isnt time2 a larger number than time1?
What the heck are you smoking :) 1060950494 is greater than 1060950062.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
September 12th, 2003, 12:15 PM
DOH! Those were reversed in my program. Then when I copied them here I put them the right way.:) When I assigned the stuff in another part of the program they got switched. so when I was debugging they were showing up reversed. Im retarded, way too much to drink last night. you can delete this post.
Last edited by samlab; September 12th, 2003 at 12:19 PM.