I have an array of Ymd dates, which can be any combination of ten given dates, divided by one day.
eg. Here is the complete set:
2011-01-01, 2011-01-02, 2011-01-03, 2011-01-04, 2011-01-05, 2011-01-06, 2011-01-07, 2011-01-08, 2011- 01-09, 2011-01-10
Arrays created from this set can be any combination of dates - all of them, one of them, several consecutive, all in a row, etc.
I am currently printing them since they are returning. For example, here is a possible result:
2011-01-02
2011-01-03
2011-01-04
2011-01-08
(what is actually printed is more like "Friday, January 2 ...", but we will stick to a simple date string)
I would like to condense it so that if there are three or more consecutive days, they become a range, for example, the above example will become the following:
2011-01-02 - 2011-01-04
2011-01-08
which will eventually become the following:
Sunday, January 2 - Tuesday, January 4
Saturday January 8th
Is there a way to scroll and check the time difference, create a start time and an end time for the range (s), and then collect the apostates?