Skip to content

Instantly share code, notes, and snippets.

@soujohnreis
Last active February 22, 2021 00:41
Show Gist options
  • Save soujohnreis/e3671236fd3920fc30f774477de8e734 to your computer and use it in GitHub Desktop.
Save soujohnreis/e3671236fd3920fc30f774477de8e734 to your computer and use it in GitHub Desktop.
let fromDate = Date()
let toDate = Date()
let calendar = Calendar.current
let components = DateComponents(hour:0 , minute: 0, second: 0)
guard let startDate = calendar.date(byAdding: .day, value: -1, to: from) else {
return
}
calendar.enumerateDates(startingAfter: startDate, matching: components, matchingPolicy: .nextTime) { date, strict, stop in
guard let date = date else { return }
if date == nil || date > toDate {
stop = true
return
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment