-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcurrent-total-timer.component.ts
More file actions
38 lines (33 loc) · 1.21 KB
/
current-total-timer.component.ts
File metadata and controls
38 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Component, input } from '@angular/core';
import { InfoBackgroundComponent } from '../info-background/info-background.component';
import TypographyComponent from '../typography/typography.component';
import HStackComponent from '../hstack/hstack.component';
import VStackComponent from '../vstack/vstack.component';
@Component({
selector: 'current-total-timer',
templateUrl: './current-total-timer.component.html',
styleUrls: ['./current-total-timer.component.css'],
standalone: true,
imports: [InfoBackgroundComponent, TypographyComponent, HStackComponent, VStackComponent]
})
export default class CurrentTotalTimerComponent {
currentTime = input<number>(0);
totalTime = input<number>(0);
getCurrentTime() {
return this.formatTime(this.currentTime());
}
getTotalTime() {
return this.formatTime(this.totalTime());
}
/**
* Formats the given time.
*
* @param time the time to format.
* @returns the time as a string in the given format: 00:00 (leading zeros included).
*/
formatTime(time: number) {
const minutes = Math.floor(time / 60);
const seconds = Math.floor(time % 60);
return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
}
}