yes, see my previous message; you should NSLogged a NSDate object
Cheers! On Fri, Mar 20, 2009 at 2:17 PM, Charles E. Heizer <heiz...@llnl.gov> wrote: > Thanks, > No it's just playing around right now. It would be nice to be able to > specify if you wanted NSDate to be sub-second or second precision based. > > Just as question, can NSDate be overridden to be second precision based? > > Thanks, > - Charles > > > On Mar 20, 2009, at 2:05 PM, Mike Abdullah wrote: > >> >> On 20 Mar 2009, at 20:50, Charles E. Heizer wrote: >> >>> Hello, >>> I'm playing around with date time stuff right now and I'm trying to >>> figure out the bets way to determine if one datetime is equal to >>> another. The problem I'm running in to is "isEqualToDate" does not >>> appear to work, the NSLog statement will show two identical datetime >>> statements but I never see a "These dates are the same!". >>> >>> Can someone please tell me how I can get this to work. >>> >>> Thanks, >>> Charles >>> >>> NSDate *theDateTimeToRunAt = [NSDate dateWithString:@"2009-03-20 >>> 13:18:00 -0700"]; >>> NSDate *theCurrentDateTime = [NSDate date]; >>> while(1) >>> { >>> NSLog(@"theDateTime1=%@ | theCurrentDate=%@", theDateTimeToRunAt, >>> theCurrentDateTime); >>> if ([theDateTime1 isEqualToDate:theCurrentDate]) { >>> NSLog(@"These dates are the same!"); >>> [theDateTimeToRunAt addTimeInterval:900]; // Add 15 >>> Minutes to say >>> hi again! >>> } >>> >>> sleep(1); >>> theDate = [NSDate date]; >>> } >> >> Because quite simply the dates are not exactly the same. NSDate is >> based on NSTimeInterval which offers sub-second precision, and so it >> is pretty unlikely that fetching the current time gives you a date >> that is precisely 13:18. Instead, you want to compare the dates to see >> if current date is greater than or equal to theDateTimeToRunAt. >> >> Is this really your intention for the code though, or just an example >> method? If the former, why not just use +[NSThread sleepUntilDate:] ? >> >> Mike. >> > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/openspecies%40gmail.com > > This email sent to openspec...@gmail.com > -- -mmw _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com