mempool/frontend/src/app/shared/components/timestamp/timestamp.component.ts

25 lines
663 B
TypeScript
Raw Normal View History

2022-07-01 18:06:48 +02:00
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
@Component({
selector: 'app-timestamp',
templateUrl: './timestamp.component.html',
styleUrls: ['./timestamp.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TimestampComponent implements OnChanges {
@Input() unixTime: number;
@Input() dateString: string;
2022-07-16 15:56:36 +02:00
@Input() customFormat: string;
2022-07-01 18:06:48 +02:00
seconds: number | undefined = undefined;
2022-07-01 18:06:48 +02:00
ngOnChanges(): void {
if (this.unixTime) {
this.seconds = this.unixTime;
} else if (this.dateString) {
this.seconds = new Date(this.dateString).getTime() / 1000;
2022-07-01 18:06:48 +02:00
}
}
}