I'm working on an accounting reporting and one of the report requires a list of all post dates in last four weeks from the given date.
A post date is a last day of the week, in our case is it Sunday OR a last day of the month.
For example. If I enter 12/1/2019 then I'll the following list:
- Week 1: 12/01/2019 - 12/01/2019
- Week 1: 11/25/2019 - 11/30/2019
- Week 2: 11/18/2019 - 11/24/2019
- Week 3: 11/11/2019 - 11/17/2019
- Week 4: 11/04/2019 - 11/10/2019
As you see here, there are 5 post dates. Some times there are 4 weeks.
Here is an example of 4 post dates: End week 10/27/2019
- Week 1: 10/21/2019 - 10/27/2019
- Week 2: 10/14/2019 - 10/20/2019
- Week 3: 10/07/2019 - 10/13/2019
- Week 4: 10/01/2019 - 10/06/2019
Input value will always be Sunday, which is the end of the week.
I was wondering if there is a tested library that has this kind of functionality already instead of writing my own logic to deal with the dates.