Finding "spare time" in a day from within a list of events
Posted
by
MFB
on Programmers
See other posts from Programmers
or by MFB
Published on 2014-08-25T06:22:07Z
Indexed on
2014/08/25
10:32 UTC
Read the original article
Hit count: 278
I have a list of events which is always sorted chronologically. The start time is always followed by the end time. Times are strings formatted as 'HHmmss'.
// list of events
var events = [
'010000', // start
'013000', // end...
'053000',
'060000',
'161500',
'184500']
// desired output
var spares = [
'000000', // start
'010000', // end...
'013000',
'053000',
'060000',
'161500',
'184500',
'235959']
How can I programmatically create a new list of "spare time" from 000000
to 235959
?
PS I'm trying to do this in Javascript, but any conceptual answer or pseudo code would be helpful too.
© Programmers or respective owner