I have a collection of dates presented as follows:
[ "2020-08-20", "2020-08-20", "2020-08-21", "2020-08-24", "2020-08-25", "2020-08-25", "2020-08-25", ]
and I am in need of segregating consecutive identical dates into distinct ranges.
For instance, the desired output should be:
{date: "2020-08-20", period: 1-2}, {date: "2020-08-21", period: 3-3}, {date: "2020-08-25", period: 4-4},
{date: "2020-08-25", period: 5-7}
or simply put:
{date: "2020-08-20", period: 1-2},{date: "2020-08-25", period: 5-7}
If anyone could offer assistance with this task, it would be greatly appreciated. I attempted to utilize momentjs library for this purpose but encountered some challenges :(
Thank you in advance for any help provided