Explorer page with latest blocks. WIP
This commit is contained in:
21
frontend/src/app/shared/pipes/time-since/time-since.pipe.ts
Normal file
21
frontend/src/app/shared/pipes/time-since/time-since.pipe.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({ name: 'timeSince' })
|
||||
export class TimeSincePipe implements PipeTransform {
|
||||
transform(timestamp: number) {
|
||||
const minutes = ((new Date().getTime()) - (new Date(timestamp * 1000).getTime())) / 1000 / 60;
|
||||
if (minutes >= 120) {
|
||||
return Math.floor(minutes / 60) + ' hours';
|
||||
}
|
||||
if (minutes >= 60) {
|
||||
return Math.floor(minutes / 60) + ' hour';
|
||||
}
|
||||
if (minutes <= 1) {
|
||||
return '< 1 minute';
|
||||
}
|
||||
if (minutes === 1) {
|
||||
return '1 minute';
|
||||
}
|
||||
return Math.round(minutes) + ' minutes';
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { VbytesPipe } from './pipes/bytes-pipe/vbytes.pipe';
|
||||
import { RoundPipe } from './pipes/math-round-pipe/math-round.pipe';
|
||||
import { CeilPipe } from './pipes/math-ceil/math-ceil.pipe';
|
||||
import { ChartistComponent } from '../statistics/chartist.component';
|
||||
import { TimeSincePipe } from './pipes/time-since/time-since.pipe';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -20,12 +21,14 @@ import { ChartistComponent } from '../statistics/chartist.component';
|
||||
CeilPipe,
|
||||
BytesPipe,
|
||||
VbytesPipe,
|
||||
TimeSincePipe,
|
||||
],
|
||||
exports: [
|
||||
RoundPipe,
|
||||
CeilPipe,
|
||||
BytesPipe,
|
||||
VbytesPipe,
|
||||
TimeSincePipe,
|
||||
NgbButtonsModule,
|
||||
NgbModalModule,
|
||||
ChartistComponent,
|
||||
|
||||
Reference in New Issue
Block a user