35 lines
913 B
JavaScript

export function capitalizeFirstLetter(string) {
try {
return string[0].toUpperCase() + string.slice(1)
} catch {
return ''
}
}
export function timeStringToMinutes(timeString) {
// Extract hours, minutes, and seconds using a regular expression
const regex = /(\d+h)?\s*(\d+m)?\s*(\d+s)?/
const matches = timeString.match(regex)
// Initialize hours, minutes, and seconds to 0
let hours = 0
let minutes = 0
let seconds = 0
// If matches are found, extract the values
if (matches) {
if (matches[1]) hours = parseInt(matches[1])
if (matches[2]) minutes = parseInt(matches[2])
if (matches[3]) seconds = parseInt(matches[3])
}
// Convert everything to minutes
const totalMinutes = hours * 60 + minutes + seconds / 60
// Return the integer value of total minutes
return Math.floor(totalMinutes)
}
// Re-export the functions for backward compatibility
export {}