Vurig-Calendar
Vurig-Calendar copied to clipboard
dateSelected delegate method returns incorrect day
I still need to dive in to see why this is happening (whether it's my implementation or just Vurig) but at the moment, during March, the returned NSDate
from the dateSelected
method is correct. But when you move forward into April and beyond, the returned NSDate
is a day behind the correct value. It appears correctly on the view, but not through the method.
Can anyone else replicate this?
I'm starting to wonder whether this is something to do with timezones? It's only a problem during the winter months when the clock are one hour behind where they are in the summer.
Also, April 1 actually comes through the dateSelected
method as March 32.
When I changed the date description to [date descriptionWithLocale:[NSLocale currentLocale]] it works fine!
Enjoy!
@kaushil111 Excuse me, but could you please tell me where do you set the date description? I set it in
-(void)selectDate:(int)date
but doesn't work.. The date shows in log message is always one day earlier than the right one shown in breakpoint. It really puzzles me.
@kaushil111 where exactly (which class file / line #) do you make the change that you specified when performing the date descriptionWithLocale ?
@Lilacxyz @sogwiz Sorry for late reply.
See the below delegate method : -(void)calendarView:(VRGCalendarView *)calendarView dateSelected:(NSDate *)date { [date descriptionWithLocale:[NSLocale currentLocale]] ; } Its a timezone issue. You could also use: NSCalendar *gregorian = [ NSCalendar currentCalendar]; instead of: NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; everywhere in NSDate+convenience.m file