projects/i-components/src/lib/pipes/timeinterval.pipe.ts
Pipe to tranform a TimeRange to a formatted object used in the igx-time-picker.
Name | timeIntervalPipe |
Pure | true |
transform | ||||||
transform(timeInterval: TimeRange | string)
|
||||||
Parameters :
Returns :
any
|
import { Pipe, PipeTransform } from '@angular/core';
import { TimeRange } from '@mobilize/wms-framework';
/**
* Pipe to tranform a TimeRange to a formatted object used in the igx-time-picker.
*/
@Pipe({
name: 'timeIntervalPipe',
pure: true,
})
export class TimeInterval implements PipeTransform {
// eslint-disable-next-line @typescript-eslint/ban-types
transform(timeInterval: TimeRange | string): any {
if (!timeInterval || typeof timeInterval === 'string') {
return {
hours: 1,
minutes: 1,
seconds: 1,
};
} else {
return {
hours: timeInterval.Hours,
minutes: timeInterval.Minutes,
seconds: timeInterval.Seconds,
};
}
}
}