Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting last day of the week jumps to next week when firstDayOfWeek set to Monday #88

Open
glentregoning opened this issue May 2, 2015 · 7 comments
Assignees

Comments

@glentregoning
Copy link

Steps to reproduce:

  1. Configure [CKCalendarView firstWeekDay] to be Monday (2)
  2. Run Demo app, change to Week view
  3. Select the last day of the current week (Sunday)

Observed: The week shown jumps forward by 1 week.
Expected: The day should be selected, but the week shown should remain the same.

@MosheBerman
Copy link
Owner

Thanks for the succinct bug report.

Do you think this has to do with the firstWeekday fix you submitted last week? I think so, but I have to look at the code to see where the fix is.

I don't remember offhand, but there are probably some utility methods to determine what range of dates is being shown and then to determine if the selected day is in the visible range. Mostly, this has to do with the month view, because you can select dates in other months where weeks overlap two months.

Again, not sure, but that's where I'd start.

@glentregoning
Copy link
Author

I don' think it had to do with my change, but I haven't confirmed that.

I think the issue resides in

-(NSDate *) [NSCalendar+Juncture firstDayOfTheWeekUsingReferenceDate:(NSDate *)date andStartDay:(NSInteger)day]

We've had some luck by making the following change, but I'm not sure this is the right answer for the generalized solution (for weeks starting on anything other than Monday).

- (NSDate *)firstDayOfTheWeekUsingReferenceDate:(NSDate *)date andStartDay:(NSInteger)day
{
    // Make the calendar calculate Sunday correctly now that the week starts on Monday
    NSInteger dayOfWeek = [self weekdayInDate:date];
    if (dayOfWeek == 1) {
        dayOfWeek = 8;
    }
    NSInteger weekday = dayOfWeek-day;
    return [self dateBySubtractingDays:weekday fromDate:date];
}

@MosheBerman MosheBerman self-assigned this May 4, 2015
@MosheBerman
Copy link
Owner

Has this solution been working out for you?

@glentregoning
Copy link
Author

Actually sorry to say I've switched to using another Calendar library (as I wanted something a little more decoupled).

@MosheBerman
Copy link
Owner

That's disappointing, but I totally understand.

Which library are you using?

@glentregoning
Copy link
Author

This is the project I'm currently using. https://github.com/jonathantribouharet/JTCalendar/

@MosheBerman
Copy link
Owner

Cool. MBCalendarKit 5 moves towards that decoupling a bit with a lot of re-architecting. Most significantly, the calendar view no longer automatically installs the table view. Now, that behavior is only provided by CKCalendarViewController.

Since I doubt there's any point to keeping it open, do you mind if we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants