title: How to find if an NSDate is within a specified range?
body: <p>So, I'm having a difficult time (no pun intended) finding if an NSDate is within a specific range. Consider this: a scheduled visit between 5:00 PM and 6:00 PM. I want to find if the scheduled visit is within +/- 15 minutes of the current time. Thus my <em>safe</em> range is 4:45 PM to 6:15 PM. How can I find out if the scheduled visit is in or out of the range? Here's the code I've got so far, which doesn't work at all...</p>
  
  <pre><code>- (BOOL)isInScheduledRange {
  //    NSLog(@"Start: %f", [self.start timeIntervalSinceNow]);
  //    NSLog(@"End: %f", [self.end timeIntervalSinceNow]);
  //    
  //    if (([self.start timeIntervalSinceNow] &gt;= -900) &amp;&amp; ([self.end timeIntervalSinceNow] &lt;= 3600)) {
  //        NSLog(@"In Range");
  //        
  //        return YES;
  //    }
  //    
      NSDate *now = [[NSDate alloc] init];
  
  //    if ((([self.start timeIntervalSinceDate:now] &gt;= -900) &amp;&amp; ([self.start timeIntervalSinceDate:now] &lt;= 900)) &amp;&amp; (([self.end timeIntervalSinceDate:now] &lt;= -900) &amp;&amp; ([self.end timeIntervalSinceDate:now] &gt;= 900))) {
  //        NSLog(@"In Range");
  //    }
  
      NSLog(@"%@; %@; %@", now, self.start, self.end);
  //    NSLog(@"%@; %@", [self.start timeIntervalSinceDate:now], [self.end timeIntervalSinceDate:now]);
  
      if ((([self.start timeIntervalSinceDate:now] &gt;= -900) &amp;&amp; ([self.start timeIntervalSinceDate:now] &lt;= 0)) &amp;&amp; (([self.end timeIntervalSinceDate:now] &gt;= 0) &amp;&amp; ([self.end timeIntervalSinceDate:now] &lt;= 900))) {
          NSLog(@"In Range");
      }
  
      return NO;
  
      [now release];
  }
  </code></pre>
  
  <p>I'd appreciate some help. I'm having difficulties with this time calculation.</p>
  
  <p>On a separate note, I hate dealing with time no matter what platform I'm working with...</p>