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
Steve,
We're using Xamarin, which might be making a difference (but I don't imagine it would be). If I break inside the MonthViewDayTapped event, the date lists as 03/07/2014 23:00. Are you saying it's apples code built into NSDate that is causing it to appear correctly, even in Intellisense?
Hello Fergal,
The IGCalendarView just creates a date using the current NSCalendar and the default locale(although this is customizable). The date created simply uses the Month, Day and year, with no time specified. Thats all that is returned, no additional modifications are made to the NSDate. If you were to simply print the description of the date in question, it would at that point localize it to the time, and since the time is 00:00:00, it could at that point change days, but again the raw date provided has no ties to a specific time zone.
The code provided to you by my colleague will always provide you will always provide you with the correct date information.
-SteveZ
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
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.