iosswiftcalendarkitxcode12.3

Value of type 'Date' has no member 'format' & Value of type 'Date' has no member 'hours'


I have added CalendarKit in my project using swift package Manager, I tried with cocoapods as well but still I am getting the below errors:
I have added import CalendarKit as well.
1) Value of type 'Date' has no member 'format'

let timezone = TimeZone.ReferenceType.default
        var info:[String] = ["Booking Id: \(bookingDetails.bookingID ?? -1)", "Booking Type: \(bookingDetails.bookingType!)"]
        info.append("Booking From : \(begining.format(with: "dd.MM.YYYY", timeZone: timezone)) \nBooking To : \(ending.format(with: "dd.MM.YYYY", timeZone: timezone))")
        info.append("Timing: \(begining.format(with: "HH:mm")) - \(ending.format(with: "HH:mm"))")
        info.append("Status: \(status)\n")   

2) Value of type 'Date' has no member 'hours'

 if indexPath.section == 1 {
                    selectedbookingRecord = self.upcomingBookings![indexPath.row] as BookingInfoList
                    if let bookingStartDateTime = selectedbookingRecord?.bookingFrom {
                        if (bookingStartDateTime.toDate()?.hours(from: Date()))! < 24 {
                            DispatchQueue.main.async {
                                Alert().showAlert(ALERT_TITLE, message: GlobalConstants.CANNOT_DELETE_BOOKING, okButtonTitle: ALERT_OK_TITLE, CompletionHandler: nil, View: self)
                            }
                            return
                        }
                    }
                }

Thanks in advance!


Solution

  • It looks like the provided code has been developed with the older version of CalendarKit which had a dependency on DateToolsSwift. Now, when the dependency has been removed, the code you've provided doesn't compile.

    In order to resolve your issue, either use an older version of CalendarKit (not greater than 0.14.0, e.g. 0.13.14 would do just fine),

    or, just install and import DateTools independently to the files where you're using that framework.