mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
24 lines
573 B
TypeScript
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;
|
|
}
|
|
|
|
}
|