Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events not showing on selecting date #314

Open
nitishrana28 opened this issue Apr 20, 2017 · 0 comments
Open

Events not showing on selecting date #314

nitishrana28 opened this issue Apr 20, 2017 · 0 comments

Comments

@nitishrana28
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant