I'm making my custom calendar view for an app for the European market. In a function I should get number of day of week... I do, but it returns the number of the day of week starting with Sunday. How should I hardcode returning this number starting with Monday? Thanks Here is what I have so far:
-(int)getWeekDay:(NSDate*)date_
{
NSLocale *frLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setLocale:frLocale];
NSDateComponents *comps = [gregorian components:NSWeekdayCalendarUnit fromDate:date_];
int weekday = [comps weekday];
NSLog(@"Week day is %i", weekday);
return weekday;
}
You should use [NSCalendar setFirstWeekday:]
to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With