// Angular Core
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'time',
  standalone: false
})
export class TimePipe implements PipeTransform {

  transform(value: any, from: any, to: any, interval: any): any {

    let input = value;
    from = parseInt(from, 10);
    to = parseInt(to, 10);
    interval = parseInt(interval, 10);

    for (var i = from, y = 0; i <= to; ++i, y += interval) {
      if (i < to) {
        for (var y = 0; y < 60; y += interval) {
          input.push(((i % 12) || 12) + ":" + (y === 0 ? '00' : y) + " " + (i >= 12 && i !== 24 ? 'pm' : 'am'));
        }
      }
      if (i === to) {
        y = 0;
        input.push(((i % 12) || 12) + ":" + (y === 0 ? '00' : y) + " " + (i >= 12 && i !== 24 ? 'pm' : 'am'));
      }
    }

    return input;

  }

}
