1 2 3 4 5 6 7 8 9 10 11 12 13
| func getCurrentHour() -> Int { let calendar = Calendar.current let dateComponets = calendar.dateComponents([Calendar.Component.year, Calendar.Component.month, Calendar.Component.day, Calendar.Component.hour, Calendar.Component.weekday], from: Date()) return (dateComponets.hour!) }
func getCurrentWeekday() -> Int { let calendar = Calendar.current let dateComponets = calendar.dateComponents([Calendar.Component.year, Calendar.Component.month, Calendar.Component.day, Calendar.Component.hour, Calendar.Component.weekday], from: Date()) return (dateComponets.weekday! - 1) }
|