I have googled out about how to mark date in tapku library. According to them i have code below for JSON i get, but it show mark either to whole calender or none date.
Here is my JSON
data: [
{
id: "2",
repeat: "0",
allDay: false,
title: "All Day Event",
start: "2014-01-01 00:00:00",
end: "2014-01-01 00:00:00",
rend: ""
},
{
id: "3",
repeat: "0",
allDay: false,
title: "Long Event",
start: "2014-01-07 00:00:00",
end: "2014-01-10 00:00:00",
rend: ""
},
{
id: "4",
repeat: "0",
allDay: false,
title: "Repeating Event",
start: "2014-01-09 16:00:00",
end: "2014-01-09 16:00:00",
rend: ""
},
]
And here is my code.
-(NSArray*) calendarMonthView:(TKCalendarMonthView*)monthView marksFromDate:( NSDate*)startDate toDate:(NSDate*)lastDate{
NSMutableArray *marks = [NSMutableArray array];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
for (NSDictionary *dict in APPDELEGATE.calenderDataArray) {
NSString *startdate=[[[dict objectForKey:@"start"] componentsSeparatedByString:@" "] objectAtIndex:0];
NSString *enddate=[[[dict objectForKey:@"end"] componentsSeparatedByString:@" "] objectAtIndex:0];
NSArray *CalenderDays=[NSArray arrayWithObjects:
[NSString stringWithFormat:@"%@",startdate], nil];
NSDate *d = startDate;
NSString * dateStart = [dateFormat stringFromDate:startDate];
NSLog(@"datestart==%@",dateStart);
NSLog(@"CalenderDays==%@",CalenderDays);
while(YES){
if ([CalenderDays containsObject:dateStart]) {
[marks addObject:[NSNumber numberWithBool:YES]];
} else {
[marks addObject:[NSNumber numberWithBool:NO]];
}
NSDateComponents *info = [d dateComponentsWithTimeZone:self.monthView.timeZone];
info.day++;
d = [NSDate dateWithDateComponents:info];
if([d compare:lastDate]==NSOrderedDescending) break;
}
}
NSLog(@"MarkArray %@",marks); //marks null value
return [NSArray arrayWithArray:marks];
}
I want to show date from JSON
to tapku calender.
But i didn't get success.