Skip to content

Commit 4c381f3

Browse files
committed
fix: sonar
1 parent f3f4209 commit 4c381f3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/tools/duration-calculator/duration-calculator.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export function computeDuration(s: string): {
3232
errors: string[]
3333
} {
3434
const lines: DurationLine[] = s.split('\n').filter(l => l && !/^\s*#/.test(l)).map((l) => {
35-
const isNeg = /^\s*\-/.test(l);
36-
const cleanedDuration = l.replace(/^\s*[\+-]\s*/, '');
35+
const isNeg = /^\s*-/.test(l);
36+
const cleanedDuration = l.replace(/^\s*[+-]\s*/, '');
3737
const durationMS = convertDurationMS(cleanedDuration);
3838
return {
3939
rawLine: l,
4040
cleanedDuration,
4141
sign: isNeg ? -1 : 1,
4242
durationMS,
43-
isValid: !(typeof durationMS === 'undefined'),
43+
isValid: typeof durationMS !== 'undefined',
4444
};
4545
});
4646

@@ -123,5 +123,7 @@ function hhmmss(milliseconds: number, days: boolean) {
123123
d = Math.floor(h / 24);
124124
h = h % 24;
125125
}
126-
return `${d > 0 ? `${d}d ` : ''}${padNumber(h)}:${padNumber(m)}:${padNumber(s)}${ms > 0 ? `.${ms}` : ''}`;
126+
const formatted_d = d > 0 ? `${d}d ` : '';
127+
const formatted_ms = ms > 0 ? `.${ms}` : '';
128+
return `${formatted_d}${padNumber(h)}:${padNumber(m)}:${padNumber(s)}${formatted_ms}`;
127129
}

0 commit comments

Comments
 (0)