My Problem, in my app i used to show event for each week (week starts with monday), on next button i will be calculating next week dates, my working was working fine , but for a specific day it not returning proper value ,
following is my code
with current week end date , i will add one day to it to get next week start date
NSDateComponents *dateComponet = [[NSDateComponents alloc] init];
[dateComponet setDay:days];
return [[self getCustomCalendar] dateByAddingComponents:dateComponet toDate:date options:0];
where [self getCustomeCalendar] is,
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setLocale:[NSLocale currentLocale]];
[gregorian setFirstWeekday:2]; // 2 monday
return gregorian;
following are the return value for some weeks,
weekend Date: 2014-02-23 00:00:00 +0000 , next weekStartDate : 2014-02-24 00:00:00 +0000
weekend Date: 2014-03-02 00:00:00 +0000 , next weekStartDate : 2014-03-03 00:00:00 +0000
weekend Date: 2014-03-09 00:00:00 +0000 , next weekStartDate : 2014-03-10 00:00:00 +0000
weekend Date: 2014-03-16 00:00:00 +0000 , next weekStartDate : 2014-03-17 00:00:00 +0000
weekend Date: 2014-03-23 00:00:00 +0000 , next weekStartDate : 2014-03-24 00:00:00 +0000
// this is the problem one
weekend Date: 2014-03-30 00:00:00 +0000 , next weekStartDate : 2014-03-30 23:00:00 +0000
as you can see all dates are returning properly by adding one day,
but for 2014-03-30 , when +1 day is added, it should return 2014-03-31 instead, it is returned with 23 hours, i couldn't able to find the cause for this issue
any idea why this is happening ?