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 1
1
export function useOutputDuration ( ) {
2
2
function durationToMinutes ( duration : string ) : number {
3
- let hours = 0
4
- let minutes = 0
3
+ let hours : number = 0
4
+ let minutes : number = 0
5
5
6
6
const lowerDuration = duration . toLowerCase ( )
7
7
8
8
if ( lowerDuration . includes ( ':' ) ) {
9
- [ hours , minutes ] = lowerDuration . split ( ':' ) . map ( part => + part . trim ( ) )
9
+ [ hours , minutes ] = lowerDuration . split ( ':' ) . map ( part => + ( part ? .trim ( ) || '0' ) )
10
10
}
11
11
else {
12
12
if ( lowerDuration . includes ( 'h' ) ) {
13
- hours = + lowerDuration . split ( 'h' ) [ 0 ] . trim ( )
13
+ hours = + ( lowerDuration . split ( 'h' ) [ 0 ] ? .trim ( ) || '0' )
14
14
const remainder = lowerDuration . split ( 'h' ) [ 1 ] || ''
15
15
16
16
if ( remainder . includes ( 'm' ) )
17
- minutes = + remainder . split ( 'm' ) [ 0 ] . trim ( )
17
+ minutes = + ( remainder . split ( 'm' ) [ 0 ] ? .trim ( ) || '0' )
18
18
else if ( / ^ \d + $ / . test ( remainder ) )
19
19
minutes = + remainder
20
20
}
21
21
else if ( lowerDuration . includes ( 'm' ) ) {
22
- minutes = + lowerDuration . split ( 'm' ) [ 0 ] . trim ( )
22
+ minutes = + ( lowerDuration . split ( 'm' ) [ 0 ] ? .trim ( ) || '0' )
23
23
}
24
24
else if ( / ^ \d + $ / . test ( lowerDuration ) ) {
25
25
minutes = + lowerDuration
You can’t perform that action at this time.
0 commit comments