My question is the REVERSE of the typical “How do I find out if an NSDate is between startDate and endDate?”
What I want to do is find ALL NSDATES (to the day, not hour or minute) that occur BETWEEN startDate and endDate. Inclusive of those dates would be preferable, although not necessary.
Example:
(I know that these don’t represent NSDates, these are just for illustration)
INPUT:
startDate = 6/23/10 20:11:30
endDate = 6/27/10 02:15:00
OUTPUT:
NSArray of: 6/23/10, 6/24/10, 6/25/10, 6/26/10, 6/27/10
I don’t mind doing the work. It’s just that I don’t know where to start in terms of making efficient code, without having to step through the NSDates little by little.
Add 24 hours to the start date until you go past the end date.
You could round the first date to noon or midnight before starting the loop if you care about the time of day.