iPhone SDK Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsMobile ProgrammingiPhone SDK Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 12th, 2010, 05:23 PM
orbitalx orbitalx is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 33 orbitalx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 52 m 31 sec
Reputation Power: 6
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

Reply With Quote
  #2  
Old April 12th, 2010, 05:30 PM
orbitalx orbitalx is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 33 orbitalx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 52 m 31 sec
Reputation Power: 6
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsMobile ProgrammingiPhone SDK Development > TimeIntervalSinceDate Returns Inaccurate Interval

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap