Skip to content

Instantly share code, notes, and snippets.

View vendruscolo's full-sized avatar

Alessandro Vendruscolo vendruscolo

View GitHub Profile
import Foundation
// https://twitter.com/peres/status/1353810351264034818
func daysBetweenDates(start: Date, end: Date, calendar: Calendar) -> [Date] {
guard let diff = cal.dateComponents([.day], from: start, to: end).day else {
return []
}
// if you need to include end in the array, use 0...diff+1
return (0...diff).compactMap {