mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-02 05:23:14 +00:00
fix a few, more to go (#2869)
* fix a few, more to go * chore: comments (#2871) * chore: comments * chore: typo * chore: stricter typescript (#2872) * chore: comments * chore: stricter typescript --------- Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com> * minor styling --------- Co-authored-by: Alex Inkin <alexander@inkin.ru>
This commit is contained in:
@@ -25,9 +25,12 @@ export function convertBytes(bytes: number): string {
|
||||
export class DurationToSecondsPipe implements PipeTransform {
|
||||
transform(duration?: string | null): number {
|
||||
if (!duration) return 0
|
||||
const [, num, , unit] =
|
||||
duration.match(/^([0-9]*(\.[0-9]+)?)(ns|µs|ms|s|m|d)$/) || []
|
||||
return Number(num) * unitsToSeconds[unit]
|
||||
|
||||
const regex = /^([0-9]*(\.[0-9]+)?)(ns|µs|ms|s|m|d)$/
|
||||
const [, num, , unit] = duration.match(regex) || []
|
||||
const multiplier = (unit && unitsToSeconds[unit]) || NaN
|
||||
|
||||
return unit ? Number(num) * multiplier : NaN
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user