File

projects/i-components/src/lib/pipes/timeinterval.pipe.ts

Description

Pipe to tranform a TimeRange to a formatted object used in the igx-time-picker.

Metadata

Name timeIntervalPipe
Pure true

Methods

transform
transform(timeInterval: TimeRange | string)
Parameters :
Name Type Optional
timeInterval TimeRange | string No
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,
      };
    }
  }
}

result-matching ""

    No results matching ""