swift 4 – 國曆轉農曆
let dateAt: String = “2016/1/1”
let dateFormatter: DateFormatter = DateFormatter()
dateFormatter.dateFormat = “yyyy/MM/dd”
let dateComps: NSDateComponents = NSCalendar(calendarIdentifier: NSCalendar.Identifier.chinese)!.components([.year, .month, .day], from: dateFormatter.date(from: dateAt)!) as NSDateComponents
print(“\(dateAt) => Chinese calendar date (Lunar): \(dateComps.month)/\(dateComps.day)”)
之前的 swift – 國曆轉農曆 已經不能用了