You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
416 B
18 lines
416 B
export function isoDurationToSeconds(isoDuration: string): number { |
|
if (!isoDuration) { |
|
return 0; |
|
} |
|
|
|
const match = isoDuration.match(/PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?/); |
|
if (!match) { |
|
return 0; |
|
} |
|
|
|
const hours = parseInt(match[1] || '0', 10); |
|
const minutes = parseInt(match[2] || '0', 10); |
|
const seconds = parseInt(match[3] || '0', 10); |
|
|
|
return hours * 3600 + minutes * 60 + seconds; |
|
} |
|
|
|
|
|
|