I'm having trouble here. Took me hours but no use. Please keep in mind I checked the heck of StackOverFlow for a fix but there isn't any.
When I convert the _date
Object from Gregorian
to Hijri
it does not convert. I know that because when I print it it still gives me the Gregorian
day. This troubles me because I want to setDate
of a UIDatePicker
and it's setting it incorrectly because the _date
is gregorian
and my UIDatePicker
object calendar set to setCalendar:_hijriCalendar
//DATE SETTING
_date = [NSDate date];
_hijriCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSIslamicCalendar];
_gregCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
unsigned units = NSYearCalendarUnit| NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *currentDateComponents = [_hijriCalendar components:units fromDate:[NSDate date]];
NSDate *islamicDate =[_hijriCalendar dateFromComponents:currentDateComponents];
NSLog(@" Current Date: %@",islamicDate); //this outputs gregorian current date not Hijri
NOTE: Guys, I don't want just print the date. I know using a NSDateFotmatter
set to the correct NSCalendar
object will do the job. But I want to convert the date to a new date to set it to my UIDatePicker
. I hope you guys get what I mean.