Calculate time from text

I have a text like this and would like to calculate the time sum.

• Introduction (03:12) - See where to check that all the available Logic sound content is downloaded and installed, that your audio and MIDI hardware is recognized by your Mac and Logic Pro X, and that your key commands are set to the defaults used throughout this series.
• Tracks & Channel Strips (04:35) - Learn how to open a new empty project, and discover the two main types of tracks and channel strips that are at the core of Logic’s DNA.
• First Look at the Main Window (07:00) - Get an overview of the workspace, including the Tracks Area, the Control Bar, and the various tabbed panels and windows.
• Working with Projects (07:10) - Explore how to save and manage project files and related assets within a project folder.
• Playback Basics (06:47) - Learn the main ways of starting and stopping playback, and locating the playhead to new positions.
• Cycle & Loop Basics (08:21) - Discover how Cycle Mode is used to continuously repeat playback of an area of the timeline, and how Looping is used to have a region continue playing throughout the timeline.

// #popclip
// name: TimeSum
// lang: javascript

function calculateTotalTime(text) {
    const timePattern = /\((\d{2}):(\d{2})\)/g;
    let match = timePattern.exec(text);
    let totalMinutes = 0;
    let totalSeconds = 0;
    while (match != null) {
        totalMinutes += parseInt(match[1]);
        totalSeconds += parseInt(match[2]);
        match = timePattern.exec(text);

    totalMinutes += Math.floor(totalSeconds / 60);
    totalSeconds = totalSeconds % 60;

    return `${totalMinutes.toString().padStart(2, '0')}:${totalSeconds.toString().padStart(2, '0')}`;


(The above block is an extension snippet — select it then click “Install Extension” in PopClip.)

CleanShot 2024-01-30 at 10.13.59