How can I make an array of time points such that I get ['00:00', '00:15', '00:30', '00:45', '01:00', '01:15', '01:30', '01:45', '02:00', ...]?
I have come up with
const timePoints = new Array(24 * 4).fill(0).map((time, i) => {
const seconds = i * 15 * 60;
const minutes = seconds / 60;
return `${Math.floor(minutes / 60)}:${seconds / 60 % 60}`;
});
console.log(timePoints);
it does work, but I actually want the array to start from the quarter that is closest to the actual time.
So if the clock says 16:35, I want it to start from '16:45', giving me an array ['16:45', '17:00', '17:15', ...].
It might be something like starting by finding the start time, creating a loop that iterates 24*4 times and then extract the hours and minutes separately and add either 0 or 1 to the hours and either add 15 or subtract 45 from the minutes.
But it might be possible to do with a more clever solution