Skip to content

Commit

Permalink
fix: sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
sharevb committed Sep 29, 2024
1 parent f3f4209 commit 4c381f3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tools/duration-calculator/duration-calculator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export function computeDuration(s: string): {
errors: string[]
} {
const lines: DurationLine[] = s.split('\n').filter(l => l && !/^\s*#/.test(l)).map((l) => {
const isNeg = /^\s*\-/.test(l);
const cleanedDuration = l.replace(/^\s*[\+-]\s*/, '');
const isNeg = /^\s*-/.test(l);
const cleanedDuration = l.replace(/^\s*[+-]\s*/, '');
const durationMS = convertDurationMS(cleanedDuration);
return {
rawLine: l,
cleanedDuration,
sign: isNeg ? -1 : 1,
durationMS,
isValid: !(typeof durationMS === 'undefined'),
isValid: typeof durationMS !== 'undefined',
};
});

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

0 comments on commit 4c381f3

Please sign in to comment.