ngx-daterangepicker
Version:
Angular PayPal Datepicker
19 lines (15 loc) • 478 B
text/typescript
import { Pipe, PipeTransform } from '@angular/core';
import * as dateFns from 'date-fns';
import {locales} from './constants';
({
name: 'ngxFormat'
})
export class NgxFormatPipe implements PipeTransform {
transform(value: Date, ...args: Array<any>): any {
let options: any = {};
if (args && args[1] && locales.hasOwnProperty(args[1])) {
options.locale = locales[args[1]];
}
return dateFns.format(value, args[0] || "DD-MM-YYYY", options);
}
}