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

Restrict date / month selection #5

Closed
hemangshah opened this issue Jul 3, 2013 · 4 comments
Closed

Restrict date / month selection #5

hemangshah opened this issue Jul 3, 2013 · 4 comments

Comments

@hemangshah
Copy link

Suppose my current date is Jul 3, 2013, I want to restrict date selection from DSLCalendarView, something like,

  1. User can't select before date from the above date

  2. Only able to select a current month date

  3. Can I set something like, user can only select dates between current month to next to next month, for eg. As current month is July, user can able to select any dates between, July, August, September.

  4. User cannot select a weekend date?

I don't know I can achieve this with the current version of DSLCalendarView or not, please do let me know asap.

@TimAEllis
Copy link

On this issue, is it also possible to allow only single day selection?

@PeteC
Copy link
Owner

PeteC commented Jul 7, 2013

This isn't currently possible, but I'll leave this issue open for a future version

@hemangshah
Copy link
Author

Thanks @PeteC for the reply, but I can customize it on my own, if you can answer me some of the questions.

  1. From which class method the date label is showing up.
  2. In which class I'll get to start customizing it easily.

@hemangshah
Copy link
Author

@PeteC

This code is given in example, should I do something with this?

- (DSLCalendarRange *)calendarView:(DSLCalendarView *)calendarView didDragToDay:(NSDateComponents *)day selectingRange:(DSLCalendarRange *)range
{
    if (NO) { // Only select a single day
        return [[DSLCalendarRange alloc] initWithStartDay:day endDay:day];
    }
    else if (NO)
        { // Don't allow selections before today
            NSDateComponents *today = [[NSDate date] dslCalendarView_dayWithCalendar:calendarView.visibleMonth.calendar];

    NSDateComponents *startDate = range.startDay;
    NSDateComponents *endDate = range.endDay;

    if ([self day:startDate isBeforeDay:today] && [self day:endDate isBeforeDay:today])
    {
        self.calendarView.selectedRange = nil;
        return nil;
    }
    else
    {
        if ([self day:startDate isBeforeDay:today])
        {
            startDate = [today copy];
        }
        if ([self day:endDate isBeforeDay:today])
        {
            endDate = [today copy];
        }

        return [[DSLCalendarRange alloc] initWithStartDay:startDate endDay:endDate];
    }
}

 return range;
}

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

No branches or pull requests

3 participants