mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 18:37:32 +00:00
WIP: chore(ci): test nx
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { DurationToSecondsPipe } from './duration-to-seconds.pipe';
|
||||
|
||||
@NgModule({
|
||||
declarations: [DurationToSecondsPipe],
|
||||
imports: [CommonModule],
|
||||
exports: [DurationToSecondsPipe],
|
||||
})
|
||||
export class DurationToSecondsPipeModule {}
|
@@ -0,0 +1,23 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { Duration } from 'google-protobuf/google/protobuf/duration_pb';
|
||||
|
||||
@Pipe({
|
||||
name: 'durationToSeconds',
|
||||
})
|
||||
export class DurationToSecondsPipe implements PipeTransform {
|
||||
transform(value?: Duration.AsObject, ...args: unknown[]): unknown {
|
||||
if (value) {
|
||||
return this.durationToSeconds(value);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
private durationToSeconds(date: Duration.AsObject): any {
|
||||
if (date?.seconds !== undefined && date?.nanos !== undefined) {
|
||||
const ms = date.seconds * 1000 + date.nanos / 1000 / 1000;
|
||||
const secs = ms / 1000;
|
||||
return `${secs.toFixed(2)} sec`;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user