更新时间:2023-11-29 12:46:16
Yeartext1,Monthtext1和Monthtext1是UITextField
Yeartext1 , Monthtext1 and Monthtext1 are UITextField
可生成的是UILabel
resultlable is UILabel
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)"
它需要一个公历2015年5月10日,并且会给您伊斯兰日期1436年12月22日
It will take an Gregorian Date 5-10-2015 and it will give you the islamic date 1436 - 12 - 22
*一天出错的可能性很小
*There is a small probability of one day error
您可以检查此转换器 http://www.islamicfinder.org/Hcal/hdate_next.php
you can check this converter http://www.islamicfinder.org/Hcal/hdate_next.php