JSFiddle - React, Tailwind, and code Playground

by igalst

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/momentjs/2.14.1/moment-with-locales.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment-range/4.0.2/moment-range.js"></script>

</body>
</html>

Babel + JSX

window['moment-range'].extendMoment(moment);

const targetRange = moment.range(moment('2020-04-11'), moment('2020-05-11'));

const periods = [
  { startDate: '2020-07-11', endDate: '2020-08-11' },
  { startDate: '2020-05-20', endDate: '2020-05-21' }
].map(({ startDate, endDate }) => moment.range(moment(startDate), moment(endDate)));
// console.log(periods)

// const period = moment.range( moment('2020-07-11'), moment('2020-08-11') );

// const nonAvailable = moment.range([period]);

// const result = targetRange.overlaps(nonAvailable);
const result = periods.some(period => targetRange.overlaps(period));

console.log(result)