text: // @flow
  
  import startOfDay from 'date-fns-legacy/start_of_day'
  import isAfter from 'date-fns-legacy/is_after'
  
  // Helper function that uses date-fns-legacy methods to determine if a date is between two other dates
  export const dateHourIsBetween = (start, candidate, end) =>
    (candidate.getTime() === start.getTime() || isAfter(candidate, start)) &&
    (candidate.getTime() === end.getTime() || isAfter(end, candidate))
  
  export const dateIsBetween = (start, candidate, end) => {
    const startOfCandidate = startOfDay(candidate)
    const startOfStart = startOfDay(start)
    const startOfEnd = startOfDay(end)
  
    return (
      (startOfCandidate.getTime() === startOfStart.getTime() || isAfter(startOfCandidate, startOfStart)) &&
      (startOfCandidate.getTime() === startOfEnd.getTime() || isAfter(startOfEnd, startOfCandidate))
    )
  }
  
  export const timeIsBetween = (start, candidate, end) =>
    candidate.getHours() >= start.getHours() && candidate.getHours() <= end.getHours()
  