weilsonwonder / WWCalendarTimeSelector

A android inspired iOS date/time picker
MIT License
317 stars 126 forks source link

How to set minimum date in calendar? #107

Open KuldeepAIP opened 4 years ago

KuldeepAIP commented 4 years ago

In my app, there's 2 option to pick date. 1. From date and 2. To date.

both options are different and action is also different. Now i want something like this.

When user pick from date then i want to allow the user to select the date between From Date to Current Date.

I have review all available option but wasn't found any property that will set minimumDate in calendar.

Simulator Screen Shot - iPhone 11 Pro Max - 2020-05-20 at 17 53 14

In above screenshot you can see i have selected 06-05-2020 as From Date now i want the user to select To Date between 06-05-2020 to 20-05-2020.

Will you please guide me how can i do that? Thanks

sibahota059 commented 4 years ago

Hi, If you still need a solution for this, just use the following datasource method from the protocol.

func WWCalendarTimeSelectorShouldSelectDate(_ selector: WWCalendarTimeSelector, date: Date) -> Bool {
        if date <= maxDate{
            return true
        }else if date >= minDate{
            return true
        }
        return false
    }
KuldeepAIP commented 4 years ago

@sibahota059 , Thanks for your help. let me try this.