oc-日历设置为周一开始。
代码:
//设置为:周一开始 --20241231
NSArray* weekArr=@[@"周一",@"周二",@"周三",@"周四",@"周五",@"周六",@"周日"];
//设置为:周一开始 --20241231
//从周日开始为1,2,3,4,5,6,7
if(firstDayOfMonth.weekday!=2){
NSInteger weekGap=firstDayOfMonth.weekday-2;
if(weekGap<0) weekGap+=7;
NSDate* firstDate=[fdate dateByAddingTimeInterval:-WHUCALENDAR_SECOND_PER_DAY*weekGap];
NSDateComponents* firstComponent=[self componentOfDate:firstDate];
for(int i=0;i<weekGap;i++){
WHUCalendarItem* item=[[WHUCalendarItem alloc] init];
item.dateStr=[NSString stringWithFormat:@"%ld-%02ld-%02ld",(long)firstComponent.year,(long)firstComponent.month,(long)firstComponent.day];
item.day=-(firstComponent.day);
[self LunarForSolarYear:item andComponent:firstComponent];
firstComponent.day++;
[dateArr addObject:item];
}
}
done

浙公网安备 33010602011771号