Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ran this code:</p> <pre><code>NSInteger day = 1; NSInteger month = 1; NSInteger year =0; NSCalendar *gregorian; NSDateComponents *components; NSDate *theDate; NSDateFormatter *dateFormatter; for (int i=2005; i&lt;2015; i++) { year= i; gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; components = [[NSDateComponents alloc] init]; [components setDay:day]; [components setMonth:month]; [components setYear:year]; theDate = [gregorian dateFromComponents:components]; [gregorian release]; dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"DD MMMM YYYY"]; NSLog(@"year=%d",year); NSLog (@"hmm: %@",[dateFormatter stringFromDate:theDate]); NSLog(@"theDate=%@\n\n",theDate); } </code></pre> <p>... and got this output:</p> <pre><code> year=2005 hmm: 01 January 2004 theDate=2005-01-01 00:00:00 -0600 year=2006 hmm: 01 January 2006 theDate=2006-01-01 00:00:00 -0600 year=2007 hmm: 01 January 2007 theDate=2007-01-01 00:00:00 -0600 year=2008 hmm: 01 January 2008 theDate=2008-01-01 00:00:00 -0600 year=2009 hmm: 01 January 2008 theDate=2009-01-01 00:00:00 -0600 year=2010 hmm: 01 January 2009 theDate=2010-01-01 00:00:00 -0600 year=2011 hmm: 01 January 2010 theDate=2011-01-01 00:00:00 -0600 year=2012 hmm: 01 January 2012 theDate=2012-01-01 00:00:00 -0600 year=2013 hmm: 01 January 2013 theDate=2013-01-01 00:00:00 -0600 year=2014 hmm: 01 January 2014 theDate=2014-01-01 00:00:00 -0600 </code></pre> <p>Clearly the problem is in the formatter and not the date. However, I don't see what could be wrong with the formatter. . </p> <p><strong>Edit:</strong></p> <p>Shifting:</p> <pre><code>[dateFormatter setDateFormat:@"DD MMMM YYYY"]; </code></pre> <p>... to:</p> <pre><code>[dateFormatter setDateFormat:@"DD MMMM yyyy"]; </code></pre> <p>... solves the problem although I don't know why. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload