File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 11export function useOutputDuration ( ) {
22 function durationToMinutes ( duration : string ) : number {
3- let hours = 0
4- let minutes = 0
3+ let hours : number = 0
4+ let minutes : number = 0
55
66 const lowerDuration = duration . toLowerCase ( )
77
88 if ( lowerDuration . includes ( ':' ) ) {
9- [ hours , minutes ] = lowerDuration . split ( ':' ) . map ( part => + part . trim ( ) )
9+ [ hours , minutes ] = lowerDuration . split ( ':' ) . map ( part => + ( part ? .trim ( ) || '0' ) )
1010 }
1111 else {
1212 if ( lowerDuration . includes ( 'h' ) ) {
13- hours = + lowerDuration . split ( 'h' ) [ 0 ] . trim ( )
13+ hours = + ( lowerDuration . split ( 'h' ) [ 0 ] ? .trim ( ) || '0' )
1414 const remainder = lowerDuration . split ( 'h' ) [ 1 ] || ''
1515
1616 if ( remainder . includes ( 'm' ) )
17- minutes = + remainder . split ( 'm' ) [ 0 ] . trim ( )
17+ minutes = + ( remainder . split ( 'm' ) [ 0 ] ? .trim ( ) || '0' )
1818 else if ( / ^ \d + $ / . test ( remainder ) )
1919 minutes = + remainder
2020 }
2121 else if ( lowerDuration . includes ( 'm' ) ) {
22- minutes = + lowerDuration . split ( 'm' ) [ 0 ] . trim ( )
22+ minutes = + ( lowerDuration . split ( 'm' ) [ 0 ] ? .trim ( ) || '0' )
2323 }
2424 else if ( / ^ \d + $ / . test ( lowerDuration ) ) {
2525 minutes = + lowerDuration
You can’t perform that action at this time.
0 commit comments