This file contains hidden or 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
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 { |
OlderNewer