JS divides array problems according to time distance, array slices for advice?

default array:

let defData = [
    {
        time: "09:00:00"
    },
    {
        time: "09:01:20"
    },
    {
        time: "09:08:00"
    },
    {
        time: "09:10:00"
    },
    {
        time: "09:11:35"
    },
    {
        time: "09:15:07"
    },
    {
        time: "09:18:00"
    },
    {
        time: "13:00:01"
    },
    {
        time: "13:00:01"
    },
    {
        time: "13:00:05"
    },
    {
        time: "13:01:32"
    },
    {
        time: "13:02:01"
    },
    {
        time: "13:05:01"
    }
];

requirement description:

my requirement is to re-divide the array in time to form a new 2-dimensional array, each member attribute contains 10 minutes of data, such a structure:

let data = [
    [
        {time: "09:00:00"},
        // ...
        {time: "09:10:00"}
    ],
    [
        {time: "09:11:00"},
        // ...
        {time: "09:20:00"}
    ]
];

I wrote a function to compare the time, but as a result, the time jump span is too large, but the time is out of breath. Ask the big god for help to give a small demo, online urgent wait! Please, this question has been stuck for almost a day.


   let defData = [{
                time: "09:00:00"
            },
            {
                time: "09:01:20"
            },
            {
                time: "09:08:00"
            },
            {
                time: "09:10:00"
            },
            {
                time: "09:11:35"
            },
            {
                time: "09:15:07"
            },
            {
                time: "09:18:00"
            },
            {
                time: "13:00:01"
            },
            {
                time: "13:00:01"
            },
            {
                time: "13:00:05"
            },
            {
                time: "13:01:32"
            },
            {
                time: "13:02:01"
            },
            {
                time: "13:05:01"
            }
        ];
        function repeatTimes(arr){
            var newArr = [];
            if(Object.prototype.toString.call(arr).slice(8,-1).toLowerCase().indexOf('array') === -1)return;
            arr.map(function(t){
                var new_time = t.time,
                    f_hour = new_time.slice(0,new_time.indexOf(':') + 1),
                    s_minute = String(Number(new_time.slice(new_time.indexOf(':') + 1,new_time.lastIndexOf(':'))) + 10),
                    t_second = new_time.slice(new_time.lastIndexOf(':'));
                newArr.push([
                    t,
                    {
                        time:f_hour + s_minute + t_second
                    }
                ])
            })
            return newArr;
        }
        //
        repeatTimes(defData);
        
        
Is that what

means? Wait a minute. I'll fix it.

Menu