Это не обязательно гарантия, но следующий код не находит календарь ни для одной локали, у которой нет диапазона дня недели, кроме 1..<8
.
let calIds: [Calendar.Identifier] = [ .buddhist, .chinese, .coptic, .ethiopicAmeteAlem, .ethiopicAmeteMihret, .gregorian, .hebrew, .indian, .islamic, .islamicCivil, .islamicTabular, .islamicUmmAlQura, .iso8601, .japanese, .persian, .republicOfChina]
for calId in calIds {
var cal = Calendar(identifier: calId)
for locId in Locale.availableIdentifiers {
let locale = Locale(identifier: locId)
cal.locale = locale
if let weekdayMin = cal.minimumRange(of: .weekday), let weekdayMax = cal.maximumRange(of: .weekday) {
if weekdayMin == weekdayMax {
if weekdayMin.startIndex != 1 || weekdayMin.count != 7 {
print("Calendar \(calId) with locale \(locId) isn't 1..<8: \(weekdayMin)")
}
} else {
print("Calendar \(calId) with locale \(locId) has a different min and max weekday range: \(weekdayMin) - \(weekdayMax)")
}
} else {
print("Calendar \(calId) with locale \(locId) doesn't have both a min and max weekday range")
}
}
}