weilsonwonder / WWCalendarTimeSelector

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

Disabling past dates #10

Closed karalarbaris closed 8 years ago

karalarbaris commented 8 years ago

Hello, Is it possible to select only certain date ranges? In my case I don't want users to be able to select past dates. Thank you.

weilsonwonder commented 8 years ago

Hi, you could implement the protocol after setting delegate to disable dates.

WWCalendarTimeSelectorShouldSelectDate(selector: WWCalendarTimeSelector, date: NSDate) -> Bool

karalarbaris commented 8 years ago

Thank you @weilsonwonder :)

RnyG commented 7 years ago

@weilsonwonder @karabar Hey guys, could you explain me how use this method in swift 2? Thanks.

RnyG commented 7 years ago

@weilsonwonder @karabar I found it! func WWCalendarTimeSelectorShouldSelectDate(selector: WWCalendarTimeSelector, date: NSDate) -> Bool { if date.timeIntervalSinceNow.isSignMinus { //myDate is earlier than Now (date and time) return false } else { //myDate is equal or after than Now (date and time) return true } }

Ali-Sher commented 6 years ago

How to change color and Disable of past time i.e Hour and minutes.. any help.

Mitesh-Mewada commented 5 years ago

hey @RnyG i set your code https://github.com/weilsonwonder/WWCalendarTimeSelector/issues/10#issuecomment-260678855 its does't work for me can you share me how to set this code, what is isSignMinus facing error how to call this function and where i set that ? swift 4

seancze commented 4 years ago

Hi @Mitesh-Mewada,

Do try this instead:

   func WWCalendarTimeSelectorShouldSelectDate(_ selector: WWCalendarTimeSelector, date: Date) -> Bool {
        if date.timeIntervalSinceNow.isLess(than: 0) {
            return false
        } else {
            return true
        }
    }