Hi,
I am trying to manipulate a string of open hours that is given to me.
It is poorly formatted and I need to bring it up to the same standard as another piece of data from a different source.
Mon-Wed 930-1700 Thu 900-1700 Fri 930-1700
Mon - Wed 930-1700 Thu 900-1700 Fri 930-1700
Mon - Thu 930-1600 Fri 930-1700
Mon - Wed 930-1700 Thu 900-1700 Fri 930-1700 Sat 900-1200
As you can see there is not always spaces between hyphens on days etc.
I need it to be separated by semicolon as follows:
Mon-Wed 930-1700;Thu 900-1700;Fri 930-1700
Mon - Wed 930-1700;Thu 900-1700;Fri 930-1700
Mon - Thu 930-1600;Fri 930-1700
Mon - Wed 930-1700;Thu 900-1700;Fri 930-1700;Sat 900-1200
Not sure if its the best/easiest solution but I had the idea to check if there is a space following a zero and if following that zero is a letter eg M, T, W, F, or S. Then I would know it is the end of one set of hours and replace the space with a semicolon. I am new to objective c and really don't know how to peek ahead or check individual characters in a NSString. This also seems like it may be a complicated solution.
Also related, I need to convert these hours from 24hr time to 12hr time. eg 1700 to 5:00pm, 0930 to 9:30am. I understand I can subtract 1200 and add the pm but how do I add the : between hour and minute and also remove the leading zero if it is before 10:00am?
Sorry for the large amount of text but I felt it was better to explain it more in the beginning.
Cheers