Skip to content

indexPathForDate: returns wrong date (1 week too early) on months starting on sunday, with NSLocale that has firstWeekday on monday. #44

@Bartlomiej-Lupinski

Description

@Bartlomiej-Lupinski

Found for February and March 2015, on NSLocale with locale identifier "pl".

Maybe the line
NSInteger dateItem = [self.calendar components:NSCalendarUnitDay fromDate:firstDayInMonth toDate:date options:0].day + (weekday - self.calendar.firstWeekday);

needs to be changed to
NSInteger dateItem = [self.calendar components:NSCalendarUnitDay fromDate:firstDayInMonth toDate:date options:0].day + (weekday >= self.calendar.firstWeekday ? weekday - self.calendar.firstWeekday : weekday - self.calendar.firstWeekday + 7);

as it seems to fix the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions