Code Quickie: Prettify a List of Dates

Code Quickie: Prettify a List of Dates

Most of the time, writing code can be very repetitive. There are only so many ways to handle something. However, a few times per project, I’m tasked to come up with a new solution to a challenge. After accepting and conquering the challenge, I sometimes come up with code that I’m very proud to share because of its elegance, simplicity, and/or novelty.

This particular challenge involved a report that produced a list of dates as parts of its results. When I ran a few sample reports, I noticed that I could potentially get a nigh unreadable list of numerous, consecutive dates. I decided to try and turn that horrible list into something beautiful by condensing three or more consecutive dates into a range.

(more…)