aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/angular
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-10-26 16:44:23 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitb5b687550d8ef8beafdf706e45d6556fb5f4c876 (patch)
tree232412d463c78af1f7ab5797db5aecf1096d08da /client/src/app/shared/shared-main/angular
parentef680f68351ec10ab73a1131570a6d14ce14c195 (diff)
downloadPeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.gz
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.zst
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.zip
Add ability to save live replay
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'