Fix: fix validation and translation

Show/hide the datepicker based on the value
This commit is contained in:
Enea Jahollari
2023-06-01 15:27:11 +02:00
parent 23eeee3d16
commit c1dcebbd04
10 changed files with 214 additions and 242 deletions

View File

@@ -0,0 +1,23 @@
import {Pipe, PipeTransform} from '@angular/core';
import {NgbDateStruct} from '@ng-bootstrap/ng-bootstrap/datepicker/ngb-date-struct';
@Pipe({
// eslint-disable-next-line @angular-eslint/pipe-prefix
name: 'toDate',
pure: false
})
export class ToDatePipe implements PipeTransform {
transform(dateValue: string | null): NgbDateStruct | null {
if (!dateValue) {
return null;
}
const date = new Date(dateValue);
return {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
} as NgbDateStruct;
}
}