Open nitishrana28 opened 7 years ago
Everything works fine for current date but none of the events for other dates are displayed. My code:
- (NSArray *) calendarDayTimelineView:(TKCalendarDayView*)calendarDayTimeline eventsForDate:(NSDate *)eventDate{ NSLog(@"eventDate : %@",eventDate); NSDateFormatter *formatter = [NSDateFormatter new]; [formatter setDateFormat:@"yyyy-MM-dd"]; [formatter setLocale:[NSLocale systemLocale]]; NSString *dateString = @""; dateString = [formatter stringFromDate:eventDate]; NSMutableArray *arr = [[CommonModel shared] GetAllCustomerArticleDetailForDayCalendar:dateString]; NSDateComponents *info = [[NSDate date] dateComponentsWithTimeZone:calendarDayTimeline.calendar.timeZone]; info.second = 0; NSMutableArray *ret = [NSMutableArray array]; for(CustomerArticleDetail *detail in arr) { [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"]; NSDate *dateStart = [formatter dateFromString:detail.StartDate]; NSDate *dateEnd = [formatter dateFromString:detail.EndDate]; [formatter setDateFormat:@"yyyy-MM-dd'T'hh:mm:ss"]; NSString *start = [formatter stringFromDate:dateStart]; NSString *end = [formatter stringFromDate:dateEnd]; TKCalendarDayEventView *event = [calendarDayTimeline dequeueReusableEventView]; if(event == nil) event = [TKCalendarDayEventView eventView]; NSInteger col = arc4random_uniform(3); [event setColorType:col]; event.identifier = [NSNumber numberWithInt:detail.Id]; event.titleLabel.text = detail.CustomerName; event.locationLabel.text = detail.Article_Details; int hours = [[[[[start componentsSeparatedByString:@"T"] objectAtIndex:1] componentsSeparatedByString:@":"] objectAtIndex:0] intValue]; int minutes = [[[[[start componentsSeparatedByString:@"T"] objectAtIndex:1] componentsSeparatedByString:@":"] objectAtIndex:1] intValue]; info.hour = hours; info.minute = minutes; event.startDate = [NSDate dateWithDateComponents:info]; hours = [[[[[end componentsSeparatedByString:@"T"] objectAtIndex:1] componentsSeparatedByString:@":"] objectAtIndex:0] intValue]; minutes = [[[[[end componentsSeparatedByString:@"T"] objectAtIndex:1] componentsSeparatedByString:@":"] objectAtIndex:1] intValue]; info.hour = hours; info.minute = minutes; event.endDate = [NSDate dateWithDateComponents:info]; [ret addObject:event]; } return ret; }
Everything works fine for current date but none of the events for other dates are displayed. My code: