#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    33
    Rep Power
    11

    time_t questions


    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.
    thanks
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,594
    Rep Power
    4207
    >> 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
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    33
    Rep Power
    11
    Originally posted by Scorpions4ever
    >> Why isnt time2 a larger number than time1?
    What the heck are you smoking :) 1060950494 is greater than 1060950062.
    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.

IMN logo majestic logo threadwatch logo seochat tools logo