How to make the st,nd,rd,th as supescript along with date and time in swift xcode 13. I have set the items in the tableviewcell
From the tableView cell I'm setting the date and time like in below code
let date = meetingListArray[indexPath.row].callScheduleDate?.dateConversion(date: meetingListArray[indexPath.row].callScheduleDate ?? "") ?? ""
let toTime = meetingListArray[indexPath.row].timeTo?.timeConverter(date: meetingListArray[indexPath.row].timeTo ?? "") ?? ""
let fromTime = meetingListArray[indexPath.row].timeFrom?.timeConverter(date: meetingListArray[indexPath.row].timeFrom ?? "") ?? ""
let time = fromTime + " -" + toTime
cell.callDateAndTime.text = date + time
I have written the the dateFormatWithSuffix(), daySuffix() as extension
func dateFormatWithSuffix() -> String {
return "MMMM dd'\(self.daySuffix())' yyyy | "
}
func daySuffix() -> String {
let calendar = Calendar.current
let components = (calendar as NSCalendar).components(.day, from: self)
let dayOfMonth = components.day
switch dayOfMonth {
case 1, 21, 31:
return "st"
case 2, 22:
return "nd"
case 3, 23:
return "rd"
default:
return "th"
}
}

