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

@Pipe({
    name: 'addHours',
    standalone: true
})
export class AddHoursPipe implements PipeTransform {

    transform(value: string, hours = 48): string {
        if (!value) return '';

        const inputDate = new Date(value);
        const outputDate = new Date(inputDate.getTime() + hours * 60 * 60 * 1000);

        const day = String(outputDate.getDate()).padStart(2, '0');
        const month = String(outputDate.getMonth() + 1).padStart(2, '0');
        const year = String(outputDate.getFullYear()).slice(-2);
        const hoursStr = String(outputDate.getHours()).padStart(2, '0');
        const minutes = String(outputDate.getMinutes()).padStart(2, '0');

        return `${day}-${month}-${year} | ${hoursStr}:${minutes}`;
    }
}
