import { Pipe , PipeTransform , LOCALE_ID , Inject } from '@angular/core' ; import { CalendarDateFormatter , DateAdapter } from 'angular-calendar' ; @ Pipe ( { name : 'calendarSchedulerDate' } ) export class CalendarSchedulerDatePipe implements PipeTransform { constructor ( private dateAdapter , private dateFormatter , @ Inject ( LOCALE_ID ) private locale ) { } transform ( date , method , locale = this . locale , weekStartsOn = 0 , excludeDays = [ ] , daysInWeek ? , startsWithToday ? ) { if ( typeof this . dateFormatter [ method ] === 'undefined' ) { const allowedMethods = Object . getOwnPropertyNames ( Object . getPrototypeOf ( CalendarDateFormatter . prototype ) ) . filter ( iMethod => iMethod !== 'constructor' ) ; throw new Error ( `${ method } is not a valid date formatter. Can only be one of ${ allowedMethods . join ( ', ' ) }` ) ; } return this . dateFormatter [ method ] ( { dateAdapter : this . dateAdapter , date , locale , weekStartsOn , excludeDays , daysInWeek , startsWithToday } ) ; } }