Note that there are some explanatory texts on larger screens.

plurals
  1. PONSDateFormatter or NSDateComponents return the same number for different dates
    text
    copied!<p>I did build a custom calendar and when I go through the week changing the day number for day, I see strange situation when date is 26, but NSDateFormatter and NSDateComponents return 27, the same is for 27 = 27, you can see a log from. In another case 31 is 30, and the 1 is 31</p> <p>Does anybody had something like that?</p> <pre><code>for (NSDictionary *dict in weekViews) { UILabel *dayName = dict[@"dayName"]; UILabel *dayNumber = dict[@"dayNumber"]; components = [calendar components:NSCalendarUnitMonth | NSCalendarUnitDay fromDate:tempDate]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"dd"; //TODO:Remove NSLog NSLog(@"%@ = %@", [formatter stringFromDate:tempDate], tempDate); dayName.text = [NSString stringWithFormat:@"%@", weekDaySymbols[index++]]; dayNumber.text = [NSString stringWithFormat:@"%d", components.day]; tempDate = [tempDate dateByAddingTimeInterval:86400]; } </code></pre> <p>2013-10-22 01:06:25.812 Care[539:70b] 27 = 2013-10-26 21:00:00 +0000</p> <p>2013-10-22 01:06:25.813 Care[539:70b] 27 = 2013-10-27 21:00:00 +0000</p> <p>2013-10-22 01:06:25.813 Care[539:70b] 28 = 2013-10-28 21:00:00 +0000</p> <p>2013-10-22 01:06:25.814 Care[539:70b] 29 = 2013-10-29 21:00:00 +0000</p> <p>2013-10-22 01:06:25.814 Care[539:70b] 30 = 2013-10-30 21:00:00 +0000</p> <p>2013-10-22 01:06:25.815 Care[539:70b] 31 = 2013-10-31 21:00:00 +0000</p> <p>2013-10-22 01:06:25.816 Care[539:70b] 01 = 2013-11-01 21:00:00 +0000</p> <p>Another examples for that code:</p> <p>2013-10-22 01:14:12.456 Care[539:70b] 22 = 2014-03-22 21:00:00 +0000</p> <p>2013-10-22 01:14:12.456 Care[539:70b] 23 = 2014-03-23 21:00:00 +0000</p> <p>2013-10-22 01:14:12.457 Care[539:70b] 24 = 2014-03-24 21:00:00 +0000</p> <p>2013-10-22 01:14:12.457 Care[539:70b] 25 = 2014-03-25 21:00:00 +0000</p> <p>2013-10-22 01:14:12.458 Care[539:70b] 26 = 2014-03-26 21:00:00 +0000</p> <p>2013-10-22 01:14:12.458 Care[539:70b] 27 = 2014-03-27 21:00:00 +0000</p> <p>2013-10-22 01:14:12.459 Care[539:70b] 28 = 2014-03-28 21:00:00 +0000</p> <p>2013-10-22 01:12:34.942 Care[539:70b] 29 = 2014-03-29 21:00:00 +0000</p> <p>2013-10-22 01:12:34.943 Care[539:70b] 31 = 2014-03-30 21:00:00 +0000</p> <p>2013-10-22 01:12:34.943 Care[539:70b] 01 = 2014-03-31 21:00:00 +0000</p> <p>2013-10-22 01:12:34.944 Care[539:70b] 02 = 2014-04-01 21:00:00 +0000</p> <p>2013-10-22 01:12:34.944 Care[539:70b] 03 = 2014-04-02 21:00:00 +0000</p> <p>2013-10-22 01:12:34.945 Care[539:70b] 04 = 2014-04-03 21:00:00 +0000</p> <p>2013-10-22 01:12:34.945 Care[539:70b] 05 = 2014-04-04 21:00:00 +0000</p> <p>I did break my brain :)</p>
 

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