iOS Question Convert Gregorian date to Islamic date

Pooya1

Active Member
Licensed User
Hi
I want to convert Gregorian date to Islamic date
I found below code in stackoverflow if it is right code
That is simple code but i dont know how do use it in B4i

B4X:
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
let GregorianDate = dateFormatter.dateFromString("\(Daytext1.text!)-\(Monthtext1.text!)-\(Yeartext1.text!)")
let islamic = NSCalendar(identifier: NSCalendarIdentifierIslamicUmmAlQura)
let components = islamic?.components(NSCalendarUnit(rawValue: UInt.max), fromDate: GregorianDate!)
resultlable.text = "\(components!.year) - \(components!.month) - \(components!.day)"

https://stackoverflow.com/questions/32893323/convert-gregorian-date-to-hijri-date
 
Last edited:
Top