Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138221

Ho can I check free time in time range

$
0
0

I have an array with different times registered

const existing = [
  {
    start: "2020-02-05T09:00:00Z",
    end: "2020-02-05T10:15:00Z"
  },
  {
    start: "2020-02-05T10:30:00Z",
    end: "2020-02-05T11:00:00Z"
  },
  {
    start: "2020-02-05T11:00:00Z",
    end: "2020-02-05T12:15:00Z"
  }
]

I want a function that return true or false, if it is possible to add another time.

If 10:00 - 11:00 is registered, it should also be possible to add 09:00-10:00. Meaning that start and end times can overlap.

The user might try to add these hours. But of cause they could choose many other hours

e.g. newStart 09:59 - newEnd 10:20

e.g. newStart 10:16 - newEnd 10:29

The problem is to compare the different objects but also time between the different objects. Any ideas


Viewing all articles
Browse latest Browse all 138221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>