views:

35

answers:

1

I'm trying to figure out how to calculate store opening times based on the way they are normally expressed. For example: Monday - Friday, 9am - 6pm. I want to know two things from this criteria. Is the store open? If it is how long will it be before it closes?

My confusion with the documentation is that NSDate calculations expect unique date data sets to perform calculations not generic as expressed above. For example NSDate expects 2010-07-12T09:00:00Z & 2010-07-12T18:00:00Z to form the start basis of the calculation and like wise for the days in between.

Do I need to create a data set for the year on this basis to calculate the results? Or is there a clever way I can get NSCalendar / NSDateComponents to do all this hard work for me?

+1  A: 

There is no simple/automatic way. You have to parse the string yourself, form two, let's say startDate and endDate (or something alike). From them you can extract the day of the week and time (that's where NSCalendar and NSDateComponents come in handy).

krzyspmac
Thanks. I figured this out and it's relatively simple to do once the data has been broken down into start and end dates as you've suggested.
Jim