If firstWeekday is not 1, and weekday is less than firstWeekday, the middleDayOfWeek will be the middle day of next week
This commit is contained in:
lin.chao 2019-10-21 16:07:14 +08:00
parent 473e88cb26
commit cdbb9ec7ca
1 changed files with 5 additions and 0 deletions

View File

@ -195,6 +195,11 @@
NSDateComponents *weekdayComponents = [self components:NSCalendarUnitWeekday fromDate:week];
NSDateComponents *componentsToSubtract = self.fs_privateComponents;
componentsToSubtract.day = - (weekdayComponents.weekday - self.firstWeekday) + 3;
// Fix https://github.com/WenchaoD/FSCalendar/issues/1100 and https://github.com/WenchaoD/FSCalendar/issues/1102
// If firstWeekday is not 1, and weekday is less than firstWeekday, the middleDayOfWeek will be the middle day of next week
if (weekdayComponents.weekday < self.firstWeekday) {
componentsToSubtract.day = componentsToSubtract.day - 7;
}
NSDate *middleDayOfWeek = [self dateByAddingComponents:componentsToSubtract toDate:week options:0];
NSDateComponents *components = [self components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour fromDate:middleDayOfWeek];
middleDayOfWeek = [self dateFromComponents:components];