Slide 30
Slide 30 text
func YMDΛ10SetʹಥͬࠐΉ(using key: YMD.Key) {
let cal = Calendar(identifier: .gregorian)
// 2000/1/1 ͔Β 2010/12/31 ·Ͱͷ͕ॲཧର
let firstDate = DateComponents(calendar: cal,
year: 2000, month: 1, day: 1).date!
let lastDate = DateComponents(calendar: cal,
year: 2010, month: 12, day: 31).date!
var ymds: Set = []
var cursor = firstDate
while cursor < lastDate {
//Χʔιϧ͕ࣔ͢YMDΛSetʹೖΕΔ
ymds.insert(YMD(
year: cal.component(.year, from: cursor),
month: cal.component(.month, from: cursor),
day: cal.component(.day, from: cursor),
keyForHashValue: key
))
//ΧʔιϧΛҰਐΊΔ
cursor = cal.date(byAdding: .day, value: 1, to: cursor)!
}
}
30