title: Getting screwy results from NSDateComponentsFormatter
body: <p>I recently learned about the new-to-iOS8 class NSDateComponentsFormatter. It lets you generate time strings for time-spans rather than dates. Pretty cool. I decided to tinker with it, and wrote some test code that creates various time-spans and logs the output. Here's my code (English and French output)</p>
  <pre><code>  NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    
    
    NSDateComponentsFormatter* formatter = [[NSDateComponentsFormatter alloc] init];
    formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleFull;
    formatter.calendar = gregorian;
    
    formatter.allowedUnits = NSCalendarUnitYear + NSCalendarUnitMonth + NSCalendarUnitDay;
    
    NSDateComponents *components = [[NSDateComponents alloc] init];
    for (int years = 1; years &lt;= 10; years++)
    {
      int days = arc4random_uniform(10);
      components.year = years;
      components.month = 3;
      components.day = days;
      NSString* outputString = [formatter stringFromDateComponents: components];
      NSLog(@&quot;For %02d years %02d days, Date Components string = '%@'&quot;, years, days, outputString);
    }
  
    NSLocale *franceLocale = [NSLocale localeWithLocaleIdentifier: @&quot;fr_FR&quot;];
    gregorian.locale = franceLocale;
    formatter.calendar = gregorian;
  
    NSLog(@&quot;--------------- French. --------------&quot;);
    for (int years = 1; years &lt;= 10; years++)
    {
      int days = arc4random_uniform(10) ;
  
      components.year = years;
      components.day = days;
  
      NSString* outputString = [formatter stringFromDateComponents: components];
      NSLog(@&quot;For %02d years %02d days, Date Components string = '%@'&quot;, years, days, outputString);
    }
  </code></pre>
  <p>(I don't log the months value since it's fixed.)</p>
  <p>Here's the output:</p>
  <pre><code>For 01 years 00 days, Date Components string = '1 year, 3 months'
  For 02 years 05 days, Date Components string = '2 years, 3 months, 5 days'
  For 03 years 01 days, Date Components string = '3 years, 3 months'
  For 04 years 06 days, Date Components string = '4 years, 3 months, 6 days'
  For 05 years 07 days, Date Components string = '5 years, 3 months, 7 days'
  For 06 years 02 days, Date Components string = '6 years, 3 months, 1 day'
  For 07 years 04 days, Date Components string = '7 years, 3 months, 4 days'
  For 08 years 02 days, Date Components string = '8 years, 3 months, 2 days'
  For 09 years 08 days, Date Components string = '9 years, 3 months, 8 days'
  For 10 years 03 days, Date Components string = '10 years, 3 months, 2 days'
  --------------- French. --------------
  For 01 years 02 days, Date Components string = '1 année, 3 mois et 2 jours'
  For 02 years 02 days, Date Components string = '2 années, 3 mois et 2 jours'
  For 03 years 05 days, Date Components string = '3 années, 3 mois et 5 jours'
  For 04 years 03 days, Date Components string = '4 années, 3 mois et 3 jours'
  For 05 years 04 days, Date Components string = '5 années, 3 mois et 4 jours'
  For 06 years 04 days, Date Components string = '6 années, 3 mois et 4 jours'
  For 07 years 04 days, Date Components string = '7 années, 3 mois et 3 jours'
  For 08 years 08 days, Date Components string = '8 années, 3 mois et 8 jours'
  For 09 years 05 days, Date Components string = '9 années, 3 mois et 5 jours'
  For 10 years 02 days, Date Components string = '10 années, 3 mois et 2 jours'
  </code></pre>
  <p>Note that in several cases the output days value in the output of the formatter does not match the days value fed into it.</p>
  <p>Does anybody know what's going wrong here? This looks an awful lot like an OS/framework bug to me.</p>
  <h2>EDIT:</h2>
  <p>I ran my test code in a Mac app, under OS X version 10.10.5 Is anybody else running 10.10.5 and can they try it?</p>
  <p>I also got one wrong answer against the 8.1 sim. (For input value 07 years, 3 months, 06 days, Date Components string = '7 years, 3 months, 5 days')</p>