aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/angular
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main/angular')
-rw-r--r--client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts32
-rw-r--r--client/src/app/shared/shared-main/angular/index.ts1
2 files changed, 33 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts b/client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts
new file mode 100644
index 000000000..29ff864ec
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts
@@ -0,0 +1,32 @@
1import { Pipe, PipeTransform } from '@angular/core'
2
3@Pipe({
4 name: 'myDurationFormatter'
5})
6export class DurationFormatterPipe implements PipeTransform {
7
8 transform (value: number): string {
9 const hours = Math.floor(value / 3600)
10 const minutes = Math.floor((value % 3600) / 60)
11 const seconds = value % 60
12
13 if (hours > 0) {
14 let result = $localize`${hours}h`
15
16 if (minutes !== 0) result += ' ' + $localize`${minutes}min`
17 if (seconds !== 0) result += ' ' + $localize`${seconds}sec`
18
19 return result
20 }
21
22 if (minutes > 0) {
23 let result = $localize`${minutes}min`
24
25 if (seconds !== 0) result += ' ' + `${seconds}sec`
26
27 return result
28 }
29
30 return $localize`${seconds} sec`
31 }
32}
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts
index 9ba815136..29f8b3650 100644
--- a/client/src/app/shared/shared-main/angular/index.ts
+++ b/client/src/app/shared/shared-main/angular/index.ts
@@ -1,4 +1,5 @@
1export * from './bytes.pipe' 1export * from './bytes.pipe'
2export * from './duration-formatter.pipe'
2export * from './from-now.pipe' 3export * from './from-now.pipe'
3export * from './infinite-scroller.directive' 4export * from './infinite-scroller.directive'
4export * from './number-formatter.pipe' 5export * from './number-formatter.pipe'