Js transform data structure

do a page for a period of time, a class for 30 minutes. The data structure that the backend wants is like this

2018-09-17|09:00-09:30,2018-09-18|09:30-11:00,2018-09-19|10:00-11:30,2018-09-20|10:30-11:00,2018-09-21|11:00-11:30,2018-09-22|11:30-12:00

I first made this data structure

setArray = [
    data:2018-09-17,
    ranges:[
        ["09:00", "09:30"],
        ["09:30", "10:00"],
        ["10:30","11:30"],
        ["11:30","12:00"]
    ],
    data:2018-09-18,
    ranges:[
        ["09:00", "09:30"],
        ["09:30", "10:00"],
        ["10:30","11:30"],
        ["11:30","12:00"]
    ], 
]
var getJson =  setArray.map(d => {
                return d.date + "|" + d.ranges.map(r => r.join("-")).join("|")
            }).join(",")

has also been successfully transformed into the desired structure of the back end through the above method. But the back end says that if several classes are contiguous, just synthesize the start and end time of an array, just like the

written above.
ranges:[
    ["09:00", "09:30"],
    ["09:30", "10:00"],
    ["10:30","11:30"],
    ["11:30","12:00"]
]

ranges:[
    ["09:00", "10:00"],
     ["10:00", "12:00"],
]

ask for help

Jun.18,2021

  

with similar requirements, it seems that the community already has many similar posts, which have been discussed more thoroughly, you can refer to them. You use "time period" to search the community.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30f45-34105.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30f45-34105.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?