novo-elements
Version:
Bullhorn's NOVO Element Repository for Angular 2
16 lines (11 loc) • 635 B
text/typescript
import { Pipe, PipeTransform, LOCALE_ID, Inject } from '@angular/core';
({ name: 'endofweekdisplay' })
export class EndOfWeekDisplayPipe implements PipeTransform {
constructor( (LOCALE_ID) private locale: string = 'en-US') { }
transform(endOfWeek: Date, startOfWeek: Date, locale: string = this.locale, method: string = 'short'): String {
if (endOfWeek.getMonth() === startOfWeek.getMonth()) {
return new Intl.DateTimeFormat(locale, { day: 'numeric' }).format(endOfWeek);
}
return new Intl.DateTimeFormat(locale, { month: method, day: 'numeric' }).format(endOfWeek);
}
}