title: How do I subtract a duration from an NSDate, but not include the weekends?
body: <p>Using today as an example, how do I determine which date it was, 230 workdays ago?</p>
  
  <p>I know how to do it iteratively with a while loop checking date and subtracting 1 if it's a workday, but I'm wondering if there is a better method.</p>
  
  <p>Also, let's take a Sunday 1 PM as an example, and subtract 3 work days and 2 hours from that  time.  First, it doesn't make sense to subtract work-time from weekends.  So it would have to move the time to 23:59:59 of Friday, and then subtract those 3 days and 2 hours.</p>
  
  <p>If it's a Monday at 1:30 AM, and I'm subtracting 5 days and 3 work-hours from that time, then the result should be Friday 22:30 PM of the previous week.</p>
  
  <hr>
  
  <p>Code to test Kevin's method:</p>
  
  <pre><code>NSCalendar *cal = [NSCalendar currentCalendar];
  NSDateComponents *dc = [[NSDateComponents new] autorelease];
  dc.month = 12;
  dc.day = 19;
  dc.year = 2011;
  dc.hour = 1;
  dc.minute = 0;
  dc.second = 0;
  
  NSDate *date = [cal dateFromComponents:dc];
  
  NSLog(@"%@", [date descriptionWithCalendarFormat:nil timeZone:nil locale:nil]);
  date = dateBySubtractingWorkOffset(date, 0, 2);
  NSLog(@"%@", [date descriptionWithCalendarFormat:nil timeZone:nil locale:nil]);
  </code></pre>
  
  <p>Output log:</p>
  
  <pre><code>2011-12-02 16:33:46.878 otest[7124:707] 2011-12-19 01:00:00 -0500
  2011-12-02 16:33:47.659 otest[7124:707] 2011-12-18 23:00:00 -0500
  </code></pre>
  
  <p>It should never be 12-18, since that's a Sunday.</p>