Hi,
I'm subscribing to the monthViewDayTapped event handler which has two parameters, IGCalendarView calView and NSDate date. the date parameter is always a day ahead of the calendar day I have tapped.
I am based in the uk and working with a group of developers in the US so presume its a time zone issue although its always the next day even when my colleagues are in the same day as myself.
Any help would be greatly appreciated.
Cheers,
Matt
Hello ,
When your environment is localized for UK environment, date parameters returns you the tapped date localized with your environment current localization settings. So if you want to get the true date you should use code like:
-(BOOL)calendarView:(IGCalendarView *)calView monthViewDayTapped:(NSDate *)date { NSCalendar* calendar = [NSCalendar currentCalendar]; NSDateComponents* comps = [calendar components:NSYearCalendarUnit |NSMonthCalendarUnit | NSDayCalendarUnit fromDate:date]; NSLog(@"Value of date is %d/%d/%d", comps.month, comps.day, comps.year); return YES; }
-(BOOL)calendarView:(IGCalendarView *)calView monthViewDayTapped:(NSDate *)date
{
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* comps = [calendar components:NSYearCalendarUnit |NSMonthCalendarUnit | NSDayCalendarUnit fromDate:date];
NSLog(@"Value of date is %d/%d/%d", comps.month, comps.day, comps.year);
return YES;
}
Please let me know if you have any further questions.
Actually, Matt has got this slightly the wrong way around.
We're in the BST timezone (UTC + 1). If we tap the 4th of July, the MonthTapped event is raised in the delegate, but the date that is returned is 3rd July 23:00. Clearly the IG code is taking the tapped date (04/07/2014 00:00) and doing a ToLocalTime conversion on it (setting the time back an hour to 03/07/2014 23:00).
Tapped Date: 4th July 2014
Date in MonthViewDayTapped: 3rd July 2014 23:00
Clearly this is a defect. No matter what time zone the user is in, the Date returned by the IGGridView should always relate to the actual date tapped. If the user taps a given date, that is the date we should see in the eventing. Whilst we can manually fix it by performing our own conversion, developers should not have to do this to make use of your product. Please log a defect for this, and keep us informed on the progress of having this fixed in the product