How to detect if dates are consecutive in Rails?
<p>I'm looking to check for consecutive dates and display them differently if they <em>are</em> consecutive. </p>

<p>I'm working with Garage Sales that have multiple dates per sale. I'd like to then cycle through each date, and group any consecutive dates to display as a group: <em>Ex: Apr 28 - Apr 30</em></p>

<p>I also need to account for non-consecutive dates:
<em>Ex: Apr 15, Apr 28 - 30</em></p>

<p>Additionally, weekly dates need to be recognized as non-consecutive (so basically avoid step checks):
<em>Ex: Apr 16, Apr 23, Apr 30</em></p>

<hr>

<p>So far, I'm taking each date that hasn't passed &amp; ordering them properly.</p>

<pre><code>garage_sale_dates.where("date &gt; ?",Time.now).order(:date)
</code></pre>

<p>Thanks for any help! Let me know if any other info is needed.</p>