4 changed files with 63 additions and 4 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
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; |
||||
} |
||||
|
||||
|
||||
Loading…
Reference in new issue