Last active
January 19, 2019 07:38
-
-
Save robertmryan/da00594ab65b87bd8505ab35bd1628aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let calendar = Calendar.current | |
let today = calendar.startOfDay(for: Date()) | |
let dayOfMonth = calendar.component(.day, from: today) | |
let daysOfMonth = calendar.range(of: .day, in: .month, for: today)! | |
let weekDaysInMonth = (daysOfMonth.lowerBound ..< daysOfMonth.upperBound) | |
.flatMap { calendar.date(byAdding: .day, value: $0 - dayOfMonth, to: today) } | |
.filter { !calendar.isDateInWeekend($0) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment