The source code comes from:
Hijri (islamic) calendar in swift التاريخ الهجري
How can I convert string date to NSDate?
I just put them together but it has some mistake with the output.
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "YYYY-MM-DD"
let GregorianDate = dateFormatter.dateFromString("\(Yeartext1.text!)-\(Monthtext1.text!)-\(Daytext1.text!)")
let islamic = NSCalendar(identifier: NSIslamicCalendar)
let components = islamic?.components(NSCalendarUnit(rawValue: UInt.max), fromDate: GregorianDate!)
resultlable.text = "\(components!.year) - \(components!.month) - \(components!.day)"
For example, the user will enter a gregorian date (2015/09/29) and it should show the Hijri year (1436/12/15) but this doesn't work.