var calendar = Calendar.current
calendar.firstWeekday = 1
let dateComponets: Set<Calendar.Component> = Set(arrayLiteral: Calendar.Component.year, Calendar.Component.month, Calendar.Component.day)
var componets = calendar.dateComponents(dateComponets, from: self.date)
componets.day = 1
let date = calendar.date(from: componets)!
//获取选中日期月份第一天星期几,因为默认日历顺序为“日一二三四五六”,所以这里返回的1对应星期日,2对应星期一,依次类推
int weekday = calendar.ordinality(of: .weekday, in: .weekOfMonth, for: date)! - 1