Question

I am using Tapku calendar control in my app. So far, I was able to use it correctly. The problem occurred when I tried to mark dates on calendar. I have following dates that need to be marked on calendar - Month is March , dates are 26, 27, 28, 30.

Now as the calendar starts display from 26-Feb to 4th April, out of which 24th feb to 28th Feb are the dates for last month, now when it comes to mark dates on calendar, the dates 26, 27, 28 are present for Feb as well as March in the calendar control frame. While trying to draw calendar data, 26, 27 , 28 dates of Feb occur first and get marked. Which is wrong. I want to mark dates for march.

I tried to change calendar control's start date and set it to start of March, but the marks were not displayed.

Following is the code that I am using:

 NSDate *date = startDate;


int r ;
int i =0;

if([sortedDatesArray count] > 0){  // check if array is not blank

while(YES){


    // int dt = 9;



    NSString *dtStr = [sortedDatesArray objectAtIndex:i];



    r = [dtStr intValue];

    TKDateInformation info = [date dateInformationWithTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
    info.day++;



    if(r + 1 == info.day){



        [dataArray addObject:[NSNumber numberWithBool:YES]];  // stores bool for date value

        if(i < [sortedDatesArray count] - 1)
            i++;
    }
    else{
        [dataArray addObject:[NSNumber numberWithBool:NO]];

    }



    date = [NSDate dateFromDateInformation:info timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
    if([date compare:end]==NSOrderedDescending) break;



}//while



}//if
Was it helpful?

Solution

Thanks Harish, Solution to this problem was to check month as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top