SOURCE

function timestamp(y,m,d){
    return dayjs(new Date(y,m-1,d)).unix()*1000
}

function computed(_a,_b){
    let [a,b] = [_a,_b].sort((prev,next)=>prev[0]-next[0])
    const time_arr = [...a,...b].sort((c,d)=>c-d)
    const a_len = a[1] - a[0]
    const b_len = b[1] - b[0]
    const diff = Math.abs(b[0] - a[1])
    const total_len =a_len+b_len+diff
    const real_len = Math.abs(b[1] - a[0])
    if(real_len===total_len) return null
    return time_arr.concat().splice(1,2)
}

const result = computed(
    [timestamp(2026,6,2),timestamp(2001,6,1),],
    [timestamp(2020,8,15),timestamp(2020,9,13)]
    

)

if(result){
    console.log(
        dayjs(result[0]).format('YYYY-MM-DD'),
        dayjs(result[1]).format('YYYY-MM-DD'),
    )
}else{
    console.log('没有交集')
}
console 命令行工具 X clear

                    
>
console