Commit ac1c1b0e authored by David黄金龙's avatar David黄金龙

完善了 最佳逻辑

parent e166af99
......@@ -14,9 +14,18 @@ class YHRangeDatePickerView2: UIView,FSCalendarDataSource, FSCalendarDelegate, F
typealias Block = (Date?) -> ()
var block: Block?
var minDate : Date?
var minDate : Date? {
didSet {
if let minDate = minDate {
maxBestDate = self.gregorian.date(byAdding: .day, value: 6, to: minDate)
}
}
}
var maxDate : Date?
//minDate + 7 - 1
var maxBestDate : Date?
static let viewH2 : CGFloat = 396//508.0 - 52.0 -20 - 50
......@@ -113,17 +122,25 @@ extension YHRangeDatePickerView2 {
func calendar(_ calendar: FSCalendar, subtitleFor date: Date) -> String? {
if let start = startDate {
if self.gregorian.compare(start, to: date, toGranularity: .day).rawValue == 0 {
return "开始"
}
}
if let end = endDate {
if self.gregorian.compare(end, to: date, toGranularity: .day).rawValue == 0 {
return "结束"
}
if let maxBestDate = maxBestDate {
print(maxBestDate)
let result = self.gregorian.compare(date, to: maxBestDate, toGranularity: .day)
if result == .orderedSame {
return "最佳"
} else if result == .orderedAscending {
if let minDate = minDate {
let result2 = self.gregorian.compare(date, to: minDate, toGranularity: .day)
if result2 == .orderedDescending {
return "最佳"
} else if result2 == .orderedSame {
return "最佳"
}
}
} else if result == .orderedDescending {
return nil
}
}
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment