src/providers/calendarDateFormatter.provider.ts
This class is responsible for all formatting of dates. There are 2 implementations available, the CalendarNativeDateFormatter
(default) which will use the Intl API to format dates, or there is the CalendarMomentDateFormatter
which uses moment.
If you wish, you may override any of the defaults via angulars DI. For example:
import { CalendarDateFormatter, DateFormatterParams } from 'angular-calendar';
class CustomDateFormatter extends CalendarDateFormatter {
public monthViewColumnHeader({date, locale}: DateFormatterParams): string {
return new Intl.DateTimeFormat(locale, {weekday: 'short'}).format(date); // use short week days
}
}
// in your component that uses the calendar
providers: [{
provide: CalendarDateFormatter,
useClass: CustomDateFormatter
}]
import { CalendarNativeDateFormatter } from './calendarNativeDateFormatter.provider';
/**
* This class is responsible for all formatting of dates. There are 2 implementations available, the `CalendarNativeDateFormatter` (default) which will use the <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Intl" target="_blank">Intl</a> API to format dates, or there is the `CalendarMomentDateFormatter` which uses <a href="http://momentjs.com/" target="_blank">moment</a>.
*
* If you wish, you may override any of the defaults via angulars DI. For example:
*
* ```
* import { CalendarDateFormatter, DateFormatterParams } from 'angular-calendar';
*
* class CustomDateFormatter extends CalendarDateFormatter {
*
* public monthViewColumnHeader({date, locale}: DateFormatterParams): string {
* return new Intl.DateTimeFormat(locale, {weekday: 'short'}).format(date); // use short week days
* }
*
* }
*
* // in your component that uses the calendar
* providers: [{
* provide: CalendarDateFormatter,
* useClass: CustomDateFormatter
* }]
* ```
*/
export class CalendarDateFormatter extends CalendarNativeDateFormatter {}