mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 11:03:05 +00:00
Fix: fix validation and translation
Show/hide the datepicker based on the value
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user