如何在波斯语中将波斯日期转换为格里高利

问题描述:

我想在swift中在波斯日期和格里高利之间转换数据。我正在研究算法来帮助我在它们之间进行转换,但我并不真正理解如何实现它们。

I want to convert data between "Persian date and Gregorian" in swift. I was looking into algorithm to help me convert between them, but I did not really understand how to implement them.

如果它们是现有的方式来完成Swift的工作请指点我。

If their is an existing way to do the job in Swift please point me to it.

提供和示例也将受到赞赏。

Providing and example will be also appreciated.

先谢谢。

Swift 3的更新:

let formatter = DateFormatter()
formatter.dateFormat = "dd/MM/yyyy"
formatter.calendar = Calendar(identifier: .gregorian)
let date = Date()
let dateInGrogrian = formatter.string(from: date)

print(dateInGrogrian)

formatter.calendar = Calendar(identifier: .persian)
formatter.dateFormat = "dd/MM/yyyy"
print("Converted date to Hijri = \(formatter.string(from: date))")