Files
dspace-angular/src/app/shared/access-control-form-container/access-control-array-form/to-date.pipe.ts
Enea Jahollari c1dcebbd04 Fix: fix validation and translation
Show/hide the datepicker based on the value
2023-06-01 15:27:11 +02:00

24 lines
573 B
TypeScript

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;
}
}