Given a startDate
and an endDate
, I am looking to split them into an array of time slots indicated by the duration provided. This is not a numerical pagination, but rather dividing a time range.
In my TypeScript code:
startDate: Date;
endDate: Date;
timeSlots: moment.Duration = moment.duration(30, 'minutes');
The startDate is 2019-11-02T11:57:00.701Z
and the endDate is 2019-11-02T13:31:00.701Z
I need assistance in splitting this time range and returning the following result:
[
{startDate: 2019-11-02T11:57:00.701Z, endDate: 2019-11-02T12:26:59.701Z}
{startDate: 2019-11-02T12:27:00.701Z, endDate: 2019-11-02T12:56:59.701Z}
{startDate: 2019-11-02T12:57:00.701Z, endDate: 2019-11-02T13:26:59.701Z}
{startDate: 2019-11-02T13:27:00.701Z, endDate: 2019-11-02T13:31:00.701Z}
]