我如何获得工作日名称,但用德语而不用英语。我尝试了这个,但是我无法获得德国的工作日。
func returnWeekDay() -> String? {
let formatter = DateFormatter()
formatter.dateFormat = "dd.MM.yyy"
formatter.timeZone = TimeZone(identifier: "de_DE")
guard let todayDate = formatter.date(from: returnFormattedDate()) else { return nil }
let nameOfDay = formatter.weekdaySymbols[Calendar(identifier: .gregorian)
.component(.weekday, from: todayDate)]
return nameOfDay
}