请帮助Swift 3中的日期。我尝试做的是: 1.获取Date数组中的第一个元素;如果不是星期一,则将此日期设置为星期一;获得下周一的日期。 2.制作一个循环:当下一个元素与当前周相关时......(执行smth)
func d2w(daily: [Date], data: [Double]) -> ([Date], [Double]) {
var weekly = [Date]()
var wdata = [Double]()
var calendar = Calendar.current
var wday = calendar.component(.weekday, from: daily[0]) - calendar.firstWeekday
//if wday != 1 { ... }
//any other solution with Sunday is the first day of week?
//while daily == *current week { wdata += data }
//weekly.append()
return (weekly, wdata)
}