Beginner: creating and using a time slot "table"

Hi,

Please help me find a solution, I'd like to inject a (5 minute) slot requirement and time period (maximum of 24 hours) to node-red say:

22 slots between 21:00 and 06:00

And have that converted into 5 minute time slots so 108 slots:

Slot 1 - 21:00:00 - 21:04:59
Slot 2 - 21:05:00 - 21:09:59
....
Slot 108 - tomorrow 05:55:00 - 05:59:59

Then a function chooses 22 of the 108 slots, so basically a slot every 25 minutes:

Slot 1
Slot 6
Slot 11
...
Then when a new slot starts send a start message and when it ends a stop message.

When a start message is received, wait 20 seconds then check a condition and if it fails try the next 5 minute slot:

Slot 1 (21:00:00 - 21:04:59) check at 21:00:20 it fails so wait and then try slot 2 (21:05:20) it passes, so send an immediate 'on' message and a subsequent 'off' message at 21:09:59. Next check slot 6 (21:25:20)... rinse... repeat...

Thanks for taking a look.

Cheers.
Richard