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

    Join Date
    Sep 2007
    Posts
    33
    Rep Power
    8

    TimeIntervalSinceDate Returns Inaccurate Interval


    I have the following code... It seems to return an inaccurate calculation. I'm relatively new to Objective C and cannot figure out what is going wrong. By my calculations the difference (in seconds) for 4 days should be somewhere closer to 346,600 than 1917995008. Am I wrong?

    Code:
    Code:
    NSDictionary *fsAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:uniquePath error:nil];
    NSDate *fileDate = [fsAttributes objectForKey:NSFileModificationDate];
    
    NSDateFormatter *format = [[NSDateFormatter alloc] init];
    [format setDateFormat:@"MMMM dd, yyyy h:mm a"];
    NSString *dateString = [format stringFromDate:fileDate];
    
    NSDate *now = [[NSDate alloc] init];
    NSString *nowString = [format stringFromDate:now];
    
    NSLog(@"Now: %@", nowString);
    NSLog(@"Cache File Date: %@", dateString);
    NSLog(@"Cache File Age in Seconds: %d", [now timeIntervalSinceDate:fileDate]);
    [format release];
    This is what gets logged to the console:
    Code:
    2010-04-12 16:15:50.611 Denver United[26329:40b] Now: April 12, 2010 4:15 PM
    2010-04-12 16:15:50.612 Denver United[26329:40b] Cache File Date: April 08, 2010 4:23 PM
    2010-04-12 16:15:50.614 Denver United[26329:40b] Cache File Age in Seconds: 1917995008
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    33
    Rep Power
    8
    Sorry, I just figured it out... I was assuming that I was looking at an integer, but I needed to be looking it as a double.

    Hope this helps someone else as retarded as I am.

IMN logo majestic logo threadwatch logo seochat tools logo