I got a set of events that I’m displaying in a UITableView. Each event has a start date and and end date, with 1-3 days between them.
I’m trying to detect if a particular date range includes the start of a month (ex: August 1st), and add a special marker to that table view cell.
I’ve read that NSDate and calendar manipulations are expensive operations and my table view is already not the fastest in the world. How can I efficiently determine if a date range includes a start of a month?
Well, thinking pragmatically, you can check the months of each date:
You can do the same for the days, and if the
endDateday value is LESS than thestartDateday value then you know you have a 1st in there somewhere. Obviously this way will only work properly if the events span less than a month (which you said they do).