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

can you explain through example. #8

Closed
chitranjank opened this issue Jul 20, 2020 · 1 comment
Closed

can you explain through example. #8

chitranjank opened this issue Jul 20, 2020 · 1 comment

Comments

@chitranjank
Copy link

can you explain through example.

Originally posted by @chitranjank in #7 (comment)

@Ljuka
Copy link
Owner

Ljuka commented Jul 21, 2020

If I get you right, you want to have selected current date and 3 days after it and for them to be disabled. So after you setup the calendar this is how it should be done:

dateRangePickerViewController.selectedStartDate = Date()
dateRangePickerViewController.selectedEndDate = Calendar.current.date(byAdding: .day, value: 3, to: Date())
let dateFormatter = DateFormatter()
        
dateFormatter.dateFormat = "yyyy-MM-dd"
let date1 = dateFormatter.string(from: Date())
let date2 = dateFormatter.string(from: Calendar.current.date(byAdding: .day, value: 1, to: Date())!)
let date3 = dateFormatter.string(from: Calendar.current.date(byAdding: .day, value: 2, to: Date())!)
let date4 = dateFormatter.string(from: Calendar.current.date(byAdding: .day, value: 3, to: Date())!)
        
dateRangePickerViewController.disabledDates = [dateFormatter.date(from: date1), dateFormatter.date(from: date2), dateFormatter.date(from: date3), dateFormatter.date(from: date3), dateFormatter.date(from: date4)] as? [Date]

@Ljuka Ljuka closed this as completed Jul 25, 2020
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