title: Comparing NSDate objects
body: <p>I have a an application that uses CoreData. One of the entities contains <code>date</code> attribute which is, well... a date. I am writing a test to check if timestamp passed to class method for that entity's class is being converted to correct <code>NSDate</code>.</p>
  
  <p>Here's my test code:</p>
  
  <pre><code>NSDate *now = [NSDate date];
  NSTimeInterval ts = [now timeIntervalSince1970];
  // paramDict is a dictionary with attributes and values
  [paramDict setValue:[NSNumber numberWithDouble:ts] forKey:@"date"];
  
  MyEntity *myEntity = [MyEntity entityWithAttributes:paramDict inContext:testMOContext];
  
  STAssertTrue([now isEqualToDate:[myEntity date]], @"dates were not equal");
  </code></pre>
  
  <p>This is only a snippet of the whole tests which checks if all parameters were set correctly. What's interesting though is that date assertion checks fail randomly. I presume the failures has something to do with the loss of double float precision? How should I check for date in this kind of scenario?</p>
  
  <p><strong>update</strong></p>
  
  <p>The timestamp is converted to date in the method like this:</p>
  
  <pre><code>NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[paramDict valueForKey:@"date"] doubleValue]];
  [newObject setDate:date];
  </code></pre>