Vurig-Calendar icon indicating copy to clipboard operation
Vurig-Calendar copied to clipboard

dateSelected delegate method returns incorrect day

Open ed-parry opened this issue 10 years ago • 5 comments

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?

ed-parry avatar Mar 14 '14 12:03 ed-parry

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.

ed-parry avatar Mar 20 '14 18:03 ed-parry

When I changed the date description to [date descriptionWithLocale:[NSLocale currentLocale]] it works fine!

Enjoy!

kaushil111 avatar Sep 30 '14 06:09 kaushil111

@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.

CaliosD avatar Oct 11 '14 08:10 CaliosD

@kaushil111 where exactly (which class file / line #) do you make the change that you specified when performing the date descriptionWithLocale ?

sogwiz avatar Nov 06 '14 18:11 sogwiz

@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

kaushil111 avatar Nov 20 '14 10:11 kaushil111