let now = NSDate()
let calendar = NSCalendar.currentCalendar()
let startComponents = calendar.components([NSCalendarUnit.Year,.Month,.Day,.Weekday], fromDate: now)
startComponents.day += 5
let weekendDate = calendar.dateFromComponents(startComponents);
print(weekendDate);
extension NSDate {
func Year() -> Int {
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(.Year, fromDate: self)
return components.year
}
func Month() -> Int {
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(.Month, fromDate: self)
return components.month
}
func Day() -> Int {
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(.Day, fromDate: self)
return components.day
}
func WeekDay() -> Int {
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(.Weekday, fromDate: self)
return components.weekday
}
func first() -> Int {
let calendar = NSCalendar.currentCalendar()
let first = calendar.firstWeekday
return first
}
}
网友评论